[FIX] sale: avoid singleton error on SOs confirmed
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) <vfe@odoo.com> Signed-off-by: Aurélien van Delft (avd) <avd@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user