[FIX] sale_coupon: fix concurrent update on cart

Shop page link and popover use the same route which make a write on db
to recompute coupon lines. Can lead to concurent updates if unlucky on
timing.

closes odoo/odoo#39356

X-original-commit: 14253c412be8078290e808fe255c746afa79cc9c
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2019-10-24 16:38:31 +00:00
committed by fw-bot
parent 6f76b9a6ca
commit 34cbf64966
+5 -3
View File
@@ -371,9 +371,11 @@ class SaleOrder(models.Model):
coupons_to_remove.write({'state': 'new'})
# Unbind promotion and coupon programs which requirements are not met anymore
order.no_code_promo_program_ids -= programs_to_remove
order.code_promo_program_id -= programs_to_remove
order.applied_coupon_ids -= coupons_to_remove
if programs_to_remove:
order.no_code_promo_program_ids -= programs_to_remove
order.code_promo_program_id -= programs_to_remove
if coupons_to_remove:
order.applied_coupon_ids -= coupons_to_remove
# Remove their reward lines
invalid_lines |= order.order_line.filtered(lambda line: line.product_id.id in products_to_remove.ids)