diff --git a/addons/payment/__manifest__.py b/addons/payment/__manifest__.py
index 97890e9b3ce..15c69608465 100644
--- a/addons/payment/__manifest__.py
+++ b/addons/payment/__manifest__.py
@@ -23,6 +23,7 @@
'views/res_partner_views.xml',
'security/ir.model.access.csv',
'security/payment_security.xml',
+ 'wizards/payment_link_wizard_views.xml',
],
'installable': True,
'auto_install': True,
diff --git a/addons/payment/wizards/__init__.py b/addons/payment/wizards/__init__.py
index ca76ffc555b..938cc12dadf 100644
--- a/addons/payment/wizards/__init__.py
+++ b/addons/payment/wizards/__init__.py
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import payment_acquirer_onboarding_wizard
+from . import payment_link_wizard
diff --git a/addons/payment/wizards/payment_link_wizard.py b/addons/payment/wizards/payment_link_wizard.py
new file mode 100644
index 00000000000..2eb17a5b32b
--- /dev/null
+++ b/addons/payment/wizards/payment_link_wizard.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models, _
+from odoo.exceptions import ValidationError
+
+
+class PaymentLinkWizard(models.TransientModel):
+ _name = "payment.link.wizard"
+ _description = "Generate Payment Link"
+
+ @api.model
+ def default_get(self, fields):
+ res = super(PaymentLinkWizard, self).default_get(fields)
+ res_id = self._context.get('active_id')
+ res_model = self._context.get('active_model')
+ res.update({'res_id': res_id, 'res_model': res_model})
+ if res_id and res_model == 'account.invoice':
+ record = self.env[res_model].browse(res_id)
+ res.update({
+ 'description': record.reference,
+ 'amount': record.amount_total,
+ 'currency_id': record.currency_id.id,
+ 'partner_id': record.partner_id.id,
+ 'amount_max': record.amount_total
+ })
+ return res
+
+ res_model = fields.Char('Related Document Model', required=True)
+ res_id = fields.Integer('Related Document ID', required=True)
+ amount = fields.Monetary(currency_field='currency_id', required=True)
+ amount_max = fields.Monetary(currency_field='currency_id')
+ currency_id = fields.Many2one('res.currency')
+ partner_id = fields.Many2one('res.partner')
+ link = fields.Char(string='Payment Link')
+ description = fields.Char('Payment Ref')
+
+ @api.onchange('amount', 'description')
+ def _onchange_amount(self):
+ if self.amount_max < self.amount:
+ raise ValidationError(_("Please set an amount smaller than %s.") % (self.amount_max))
+ if self.amount <= 0:
+ raise ValidationError(_("The value of the payment amount must be positive."))
+ base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
+ self.link = '%s/website_payment/pay?reference=%s&amount=%s¤cy_id=%s&partner_id=%s' % (base_url, self.description, self.amount, self.currency_id.id, self.partner_id.id)
diff --git a/addons/payment/wizards/payment_link_wizard_views.xml b/addons/payment/wizards/payment_link_wizard_views.xml
new file mode 100644
index 00000000000..88e8c4e1e21
--- /dev/null
+++ b/addons/payment/wizards/payment_link_wizard_views.xml
@@ -0,0 +1,38 @@
+
+
+
+ payment.link.wizard.form
+ payment.link.wizard
+
+
+
+
+
+
+
diff --git a/addons/sale/__manifest__.py b/addons/sale/__manifest__.py
index 103675543d6..57daaf17cfc 100644
--- a/addons/sale/__manifest__.py
+++ b/addons/sale/__manifest__.py
@@ -35,6 +35,7 @@ This module contains all the common features of Sales Management and eCommerce.
'views/product_attribute_views.xml',
'views/product_views.xml',
'views/utm_campaign_views.xml'
+ 'wizard/sale_payment_link_views.xml',
],
'demo': [
'data/sale_demo.xml',
diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py
index 09f069f85ed..f2750c30fa5 100644
--- a/addons/sale/wizard/__init__.py
+++ b/addons/sale/wizard/__init__.py
@@ -3,3 +3,4 @@
from . import payment_acquirer_onboarding_wizard
from . import sale_make_invoice_advance
+from . import sale_payment_link
diff --git a/addons/sale/wizard/sale_payment_link.py b/addons/sale/wizard/sale_payment_link.py
new file mode 100644
index 00000000000..7c338ac6405
--- /dev/null
+++ b/addons/sale/wizard/sale_payment_link.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, models
+
+
+class SalePaymentLink(models.TransientModel):
+ _inherit = "payment.link.wizard"
+ _description = "Generate Sales Payment Link"
+
+ @api.model
+ def default_get(self, fields):
+ res = super(SalePaymentLink, self).default_get(fields)
+ if res['res_id'] and res['res_model'] == 'sale.order':
+ record = self.env[res['res_model']].browse(res['res_id'])
+ res.update({
+ 'description': record.name,
+ 'amount': record.amount_total - sum(record.invoice_ids.mapped('amount_total')),
+ 'currency_id': record.currency_id.id,
+ 'partner_id': record.partner_id.id,
+ 'amount_max': record.amount_total
+ })
+ return res
+
+ @api.onchange('amount', 'description')
+ def _onchange_amount(self):
+ res = super(SalePaymentLink, self)._onchange_amount()
+ if self.res_model == 'sale.order':
+ self.link = "%s&order_id=%d" % (self.link, self.res_id)
+ return res
diff --git a/addons/sale/wizard/sale_payment_link_views.xml b/addons/sale/wizard/sale_payment_link_views.xml
new file mode 100644
index 00000000000..2cc4d95eaba
--- /dev/null
+++ b/addons/sale/wizard/sale_payment_link_views.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+