mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: Add payment link folio wizard
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
</a>
|
||||
<p>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.</p>
|
||||
|
||||
@@ -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
|
||||
|
||||
59
pms/wizards/folio_payment_link.py
Normal file
59
pms/wizards/folio_payment_link.py
Normal file
@@ -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()
|
||||
14
pms/wizards/folio_payment_link_views.xml
Normal file
14
pms/wizards/folio_payment_link_views.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="action_folio_generate_link" model="ir.actions.act_window">
|
||||
<field name="name">Generate a Payment Link</field>
|
||||
<field name="res_model">payment.link.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="payment.payment_link_wizard_view_form" />
|
||||
<field name="target">new</field>
|
||||
<field name="binding_model_id" ref="model_pms_folio" />
|
||||
<field name="binding_view_types">form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user