[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) <mmeg@odoo.com>
This commit is contained in:
Mattis Megevand (mmeg)
2024-03-29 09:12:20 +00:00
committed by Mattis Megevand
parent 8d99f2f415
commit a04942c9aa
+7 -3
View File
@@ -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'}