From 5f41ddc49e2ba0ec2ba3c98e4bbd63dd2fbae5cb Mon Sep 17 00:00:00 2001 From: "Aurelien van Delft (avd)" Date: Tue, 30 Jan 2024 13:42:30 +0000 Subject: [PATCH] [FIX] sale: avoid singleton error on SOs confirmed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to changes in 82314364c6029a83 the auto-lock settings also works for public users. But, going from self.env.user to self.create_uid to check the group lead to a traceback when self.create_uid is not a singleton. This is because has_group expects a single record. To fix that, this commits checks the group of the create_uid of the first record in self. Because sale.group_auto_done_setting is an implied_group of a res.config.settings parameter, it's enough to only check for the first record in the recordset. To reproduce: - Install sale - Create a quotation as Mitchell Admin - Create a quotation as Marc Demo - Create a cron that searches on all draft sale.orders and confirm them in batch - Run the cron -> Singleton Error closes odoo/odoo#152338 X-original-commit: dfb2eaaaf5c08c0aa46cc5eb0defdc97b35953b0 Signed-off-by: Victor Feyens (vfe) Signed-off-by: Aurélien van Delft (avd) --- addons/sale/models/sale_order.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index b53d39684cb..d5140973548 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -919,7 +919,8 @@ class SaleOrder(models.Model): context.pop('default_name', None) self.with_context(context)._action_confirm() - if self.create_uid.has_group('sale.group_auto_done_setting'): # Public user can confirm SO + 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() return True