[FIX] website_sale: fix traceback with express checkout
It can happen that the payment transaction route is called without the amount kwargs, the code would crash in that case as we tried to access it either way. We moved the code after setting the default amount in the kwargs to avoid a crash. closes odoo/odoo#105576 X-original-commit: c124fb3292439a6237f16eff406c0a7d375cab65 Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
@@ -1732,9 +1732,6 @@ class PaymentPortal(payment_portal.PaymentPortal):
|
||||
if order_sudo.state == "cancel":
|
||||
raise ValidationError(_("The order has been canceled."))
|
||||
|
||||
if tools.float_compare(kwargs['amount'], order_sudo.amount_total, precision_rounding=order_sudo.currency_id.rounding):
|
||||
raise ValidationError(_("The cart has been updated. Please refresh the page."))
|
||||
|
||||
kwargs.update({
|
||||
'reference_prefix': None, # Allow the reference to be computed based on the order
|
||||
'sale_order_id': order_id, # Include the SO to allow Subscriptions to tokenize the tx
|
||||
@@ -1742,6 +1739,10 @@ class PaymentPortal(payment_portal.PaymentPortal):
|
||||
kwargs.pop('custom_create_values', None) # Don't allow passing arbitrary create values
|
||||
if not kwargs.get('amount'):
|
||||
kwargs['amount'] = order_sudo.amount_total
|
||||
|
||||
if tools.float_compare(kwargs['amount'], order_sudo.amount_total, precision_rounding=order_sudo.currency_id.rounding):
|
||||
raise ValidationError(_("The cart has been updated. Please refresh the page."))
|
||||
|
||||
tx_sudo = self._create_transaction(
|
||||
custom_create_values={'sale_order_ids': [Command.set([order_id])]}, **kwargs,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user