From dedbd6df063eb0ffe81ecccc6b3b7f6ee7deaafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 3 Apr 2025 17:21:15 +0200 Subject: [PATCH] Reset to quotation Shopify sale with insufficient authorized payment amount Shopify order can be modified from the admin in such way that the total increase and it is only partially paid. In such case we must prevent to process the sale by resetting to quotation until being fully paid. Closes #13961 --- modules/web_shop_shopify/web.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/web_shop_shopify/web.py b/modules/web_shop_shopify/web.py index 84f72ddfc0..120ec118fa 100644 --- a/modules/web_shop_shopify/web.py +++ b/modules/web_shop_shopify/web.py @@ -575,7 +575,18 @@ class Shop(metaclass=PoolMeta): Decimal(order.current_total_price) - sale.total_amount) Sale.store_cache(to_update.keys()) Amendment._clear_sale(to_update.keys()) - Sale.__queue__.process(to_update.keys()) + to_process, to_quote = [], [] + for sale in to_update: + if sale.payment_amount_authorized >= sale.amount_to_pay: + to_process.append(sale) + else: + to_quote.append(sale) + if to_process: + Sale.__queue__.process(to_process) + if to_quote: + # Use write because there is no transition + Sale.write(to_quote, {'state': 'quotation'}) + cls.log(to_quote, 'transition', 'state:quotation') @classmethod def check_modification(cls, mode, shops, values=None, external=False):