diff --git a/addons/portal/static/src/xml/portal_signature.xml b/addons/portal/static/src/xml/portal_signature.xml index 4b0ca5344d1..3ef5c8f1ea0 100644 --- a/addons/portal/static/src/xml/portal_signature.xml +++ b/addons/portal/static/src/xml/portal_signature.xml @@ -15,8 +15,8 @@
-
- +
+
diff --git a/addons/sale_payment/controllers/payment.py b/addons/sale_payment/controllers/payment.py index f06d0aa3aa7..1d00409a204 100644 --- a/addons/sale_payment/controllers/payment.py +++ b/addons/sale_payment/controllers/payment.py @@ -94,9 +94,9 @@ class PaymentPortal(http.Controller): # proceed to the payment res = tx.confirm_sale_token() - if res is not True and res != 'authorized_sale': - params['error'] = res - return request.redirect(_build_url_w_params(error_url, params)) - if res != 'authorized_sale': + if tx.state != 'authorized' or not tx.acquirer_id.capture_manually: + if res is not True: + params['error'] = res + return request.redirect(_build_url_w_params(error_url, params)) params['success'] = 'pay_sale' return request.redirect(_build_url_w_params(success_url, params)) diff --git a/addons/sale_payment/models/payment.py b/addons/sale_payment/models/payment.py index 905641d34da..857ff857dfb 100644 --- a/addons/sale_payment/models/payment.py +++ b/addons/sale_payment/models/payment.py @@ -64,9 +64,7 @@ class PaymentTransaction(models.Model): _logger.info('<%s> transaction authorized, auto-confirming order %s (ID %s)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id) if self.sale_order_id.state in ('draft', 'sent'): self.sale_order_id.with_context(send_email=True).action_confirm() - return 'authorized_sale' - - if self.state == 'done': + elif self.state == 'done': _logger.info('<%s> transaction completed, auto-confirming order %s (ID %s)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id) if self.sale_order_id.state in ('draft', 'sent'): self.sale_order_id.with_context(send_email=True).action_confirm() diff --git a/addons/website_quote/models/sale_order.py b/addons/website_quote/models/sale_order.py index 3e96864c45c..6824284b84e 100644 --- a/addons/website_quote/models/sale_order.py +++ b/addons/website_quote/models/sale_order.py @@ -51,6 +51,9 @@ class SaleOrder(models.Model): template = self.env.ref('website_quote.website_quote_template_default', raise_if_not_found=False) return template and template.active and template or False + def _get_default_online_payment(self): + return 1 if self.env['ir.config_parameter'].sudo().get_param('sale.sale_portal_confirmation_options', default='none') == 'pay' else 0 + template_id = fields.Many2one( 'sale.quote.template', 'Quotation Template', readonly=True, @@ -66,7 +69,7 @@ class SaleOrder(models.Model): quote_viewed = fields.Boolean('Quotation Viewed') require_payment = fields.Selection([ (0, 'Online Signature'), - (1, 'Online Payment')], default=0, string='Confirmation Mode', + (1, 'Online Payment')], default=_get_default_online_payment, string='Confirmation Mode', help="Choose how you want to confirm an order to launch the delivery process. You can either " "request a digital signature or an upfront payment. With a digital signature, you can " "request the payment when issuing the invoice.") diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 961934eecad..190ca516d9d 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -858,9 +858,11 @@ class WebsiteSale(http.Controller): # we proceed the s2s payment res = tx.confirm_sale_token() # we then redirect to the page that validates the payment by giving it error if there's one - if res is not True and res != 'authorized_sale': - return request.redirect('/shop/payment/validate?success=False&error=%s' % res) - return request.redirect('/shop/payment/validate?success=True') + if tx.state != 'authorized' or not tx.acquirer_id.capture_manually: + if res is not True: + return request.redirect('/shop/payment/validate?success=False&error=%s' % res) + return request.redirect('/shop/payment/validate?success=True') + return request.redirect('/shop/payment/validate') @http.route('/shop/payment/get_status/', type='json', auth="public", website=True) def payment_get_status(self, sale_order_id, **post):