From a04942c9aa20484e5f5c9133b71b8a907a0eddbf Mon Sep 17 00:00:00 2001 From: "Mattis Megevand (mmeg)" Date: Fri, 8 Mar 2024 09:49:21 +0000 Subject: [PATCH] [FIX] sale: disable locking of subscription sale order Steps to reproduce: - Install 'Subscriptions' - Enable 'Lock Confirmed Sales' in the settings - Make a new subscription - Invoice the subscription Issues: The subscription is now locked, this behaviour is not intended. As confirmed with the PO this settings should never affect the subscriptions. opw-3754106 closes odoo/odoo#159652 X-original-commit: b472c9e6f743aa467f7f4851ac95a367b364dfb1 Related: odoo/enterprise#59625 Signed-off-by: Mattis Megevand (mmeg) --- addons/sale/models/sale_order.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index bcdfcaa1fb5..87d74ebfc41 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -924,12 +924,16 @@ class SaleOrder(models.Model): context.pop('default_name', None) self.with_context(context)._action_confirm() - if self[:1].create_uid.has_group('sale.group_auto_done_setting'): - # Public user can confirm SO, so we check the group on any record creator. - self.action_lock() + + self.filtered(lambda so: so._should_be_locked()).action_lock() return True + def _should_be_locked(self): + self.ensure_one() + # Public user can confirm SO, so we check the group on any record creator. + return self.create_uid.has_group('sale.group_auto_done_setting') + def _can_be_confirmed(self): self.ensure_one() return self.state in {'draft', 'sent'}