diff --git a/addons/payment/controllers/portal.py b/addons/payment/controllers/portal.py
index eb102932de0..5fcc0147ab7 100644
--- a/addons/payment/controllers/portal.py
+++ b/addons/payment/controllers/portal.py
@@ -158,6 +158,8 @@ class WebsitePayment(http.Controller):
if not token_ok:
raise werkzeug.exceptions.NotFound
+ invoice_id = kw.get('invoice_id')
+
# Default values
values = {
'amount': 0.0,
@@ -183,6 +185,12 @@ class WebsitePayment(http.Controller):
except:
order_id = None
+ if invoice_id:
+ try:
+ values['invoice_id'] = int(invoice_id)
+ except ValueError:
+ invoice_id = None
+
# Check currency
if currency_id:
try:
@@ -266,6 +274,7 @@ class WebsitePayment(http.Controller):
def transaction(self, acquirer_id, reference, amount, currency_id, partner_id=False, **kwargs):
acquirer = request.env['payment.acquirer'].browse(acquirer_id)
order_id = kwargs.get('order_id')
+ invoice_id = kwargs.get('invoice_id')
reference_values = order_id and {'sale_order_ids': [(4, order_id)]} or {}
reference = request.env['payment.transaction']._compute_reference(values=reference_values, prefix=reference)
@@ -281,6 +290,8 @@ class WebsitePayment(http.Controller):
if order_id:
values['sale_order_ids'] = [(6, 0, [order_id])]
+ elif invoice_id:
+ values['invoice_ids'] = [(6, 0, [invoice_id])]
reference_values = order_id and {'sale_order_ids': [(4, order_id)]} or {}
reference_values.update(acquirer_id=int(acquirer_id))
diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js
index 59ae4b0e826..47e795d209d 100644
--- a/addons/payment/static/src/js/payment_form.js
+++ b/addons/payment/static/src/js/payment_form.js
@@ -284,6 +284,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({
'error_url': self.options.errorUrl,
'callback_method': self.options.callbackMethod,
'order_id': self.options.orderId,
+ 'invoice_id': self.options.invoiceId,
},
}).then(function (result) {
if (result) {
diff --git a/addons/payment/views/payment_templates.xml b/addons/payment/views/payment_templates.xml
index f1047c0f847..b8de80be83e 100644
--- a/addons/payment/views/payment_templates.xml
+++ b/addons/payment/views/payment_templates.xml
@@ -30,10 +30,12 @@
t-att-data-partner-id="partner_id"
t-att-data-callback-method="callback_method or ''"
t-att-data-order-id="order_id or ''"
+ t-att-data-invoice-id="invoice_id or ''"
t-att-data-mode="mode">
+
diff --git a/addons/payment/wizards/payment_link_wizard.py b/addons/payment/wizards/payment_link_wizard.py
index 53ca40e8762..ccd69ed342e 100644
--- a/addons/payment/wizards/payment_link_wizard.py
+++ b/addons/payment/wizards/payment_link_wizard.py
@@ -80,6 +80,8 @@ class PaymentLinkWizard(models.TransientModel):
)
if payment_link.company_id:
link += '&company_id=%s' % payment_link.company_id.id
+ if payment_link.res_model == 'account.move':
+ link += '&invoice_id=%s' % payment_link.res_id
payment_link.link = link
@api.model