diff --git a/pms/__manifest__.py b/pms/__manifest__.py index 6dc9d7624..396f9b312 100644 --- a/pms/__manifest__.py +++ b/pms/__manifest__.py @@ -94,6 +94,7 @@ "views/precheckin_portal_templates.xml", "wizards/wizard_massive_changes.xml", "wizards/wizard_advanced_filters.xml", + "wizards/folio_payment_link_views.xml", "views/payment_transaction_views.xml", "views/account_move_line_views.xml", "report/proforma_report_templates.xml", diff --git a/pms/static/description/index.html b/pms/static/description/index.html index b4c2b892e..3b16cc3b6 100644 --- a/pms/static/description/index.html +++ b/pms/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.option { span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -438,7 +439,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/pms/wizards/__init__.py b/pms/wizards/__init__.py index 42e35d4e5..7911df37b 100644 --- a/pms/wizards/__init__.py +++ b/pms/wizards/__init__.py @@ -7,3 +7,4 @@ from . import wizard_payment_folio from . import wizard_folio_changes from . import wizard_several_partners from . import pms_booking_duplicate +from . import folio_payment_link diff --git a/pms/wizards/folio_payment_link.py b/pms/wizards/folio_payment_link.py new file mode 100644 index 000000000..253f8354a --- /dev/null +++ b/pms/wizards/folio_payment_link.py @@ -0,0 +1,59 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from werkzeug import urls + +from odoo import api, models + + +class FolioPaymentLink(models.TransientModel): + _inherit = "payment.link.wizard" + _description = "Generate Sales Payment Link" + + @api.model + def default_get(self, fields): + res = super(FolioPaymentLink, self).default_get(fields) + if res["res_id"] and res["res_model"] == "pms.folio": + record = self.env[res["res_model"]].browse(res["res_id"]) + res.update( + { + "description": record.name, + "amount": record.pending_amount, + "currency_id": record.currency_id.id, + "partner_id": record.partner_id.id if record.partner_id else False, + "amount_max": record.pending_amount, + } + ) + return res + + def _generate_link(self): + """Override of the base method to add the folio_id in the link.""" + for payment_link in self: + if payment_link.res_model == "pms.folio": + # TODO: Review controller /website_payment/pay, + # how inherit it to add acquirers by property? + # now we send the first acquirer that has the property in pms_property_ids + folio = self.env["pms.folio"].browse(payment_link.res_id) + acquirer = self.env["payment.acquirer"].search( + [ + ("pms_property_ids", "in", folio.property_id.id), + ], + limit=1, + ) + record = self.env[payment_link.res_model].browse(payment_link.res_id) + payment_link.link = ( + "%s/website_payment/pay?reference=%s&amount=%s¤cy_id=%s" + "&acquirer_id=%s&partner_id=%s&folio_id=%s&company_id=%s" + "&access_token=%s" + ) % ( + record.get_base_url(), + urls.url_quote_plus(payment_link.description), + payment_link.pending_amount, + payment_link.currency_id.id, + acquirer.id if acquirer else None, + payment_link.partner_id.id if payment_link.partner_id else None, + payment_link.res_id, + payment_link.company_id.id, + payment_link.access_token, + ) + else: + super(FolioPaymentLink, payment_link)._generate_link() diff --git a/pms/wizards/folio_payment_link_views.xml b/pms/wizards/folio_payment_link_views.xml new file mode 100644 index 000000000..882ea561b --- /dev/null +++ b/pms/wizards/folio_payment_link_views.xml @@ -0,0 +1,14 @@ + + + + + Generate a Payment Link + payment.link.wizard + form + + new + + form + + +