Debian Codegraph @

addons/website_sale_loyalty/controllers/payment.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo import _
4 from odoo.exceptions import ValidationError
5
6 from odoo.addons.website_sale.controllers import payment
7
8
9 class PaymentPortal(payment.PaymentPortal):
10
11 def _validate_transaction_for_order(self, transaction, sale_order):
12 """Update programs & rewards before finalizing transaction.
13
14 :param payment.transaction transaction: The payment transaction
15 :param int order_id: The id of the sale order to pay
16 :raise: ValidationError if the order amount changed after updating rewards
17 """
18 super()._validate_transaction_for_order(transaction, sale_order)
19 if sale_order.exists():
20 initial_amount = sale_order.amount_total
21 sale_order._update_programs_and_rewards()
22 if sale_order.currency_id.compare_amounts(sale_order.amount_total, initial_amount):
23 raise ValidationError(
24 _(
25 "Cannot process payment: applied reward was changed or has expired.\n"
26 "Please refresh the page and try again."
27 )
28 )