mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 15:32:04 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -0,0 +1,28 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from odoo.addons.website_sale.controllers import payment
|
||||
|
||||
|
||||
class PaymentPortal(payment.PaymentPortal):
|
||||
|
||||
def _validate_transaction_for_order(self, transaction, sale_order):
|
||||
"""Update programs & rewards before finalizing transaction.
|
||||
|
||||
:param payment.transaction transaction: The payment transaction
|
||||
:param int order_id: The id of the sale order to pay
|
||||
:raise: ValidationError if the order amount changed after updating rewards
|
||||
"""
|
||||
super()._validate_transaction_for_order(transaction, sale_order)
|
||||
if sale_order.exists():
|
||||
initial_amount = sale_order.amount_total
|
||||
sale_order._update_programs_and_rewards()
|
||||
if sale_order.currency_id.compare_amounts(sale_order.amount_total, initial_amount):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"Cannot process payment: applied reward was changed or has expired.\n"
|
||||
"Please refresh the page and try again."
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue