[FIX] sale: forbid pricelist changes on confirmed orders

It cannot happen through the default SO form view, but some funny guys
have found other ways to do it, even though it can be quite problematic,
especially if the new pricelist is in another currency.

closes odoo/odoo#157742

Related: odoo/enterprise#58744
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2024-03-28 12:19:05 +00:00
parent 6f12d0ad42
commit dc7b75f9fb
2 changed files with 12 additions and 0 deletions
+7
View File
@@ -5022,6 +5022,13 @@ msgstr ""
msgid "You cannot cancel a locked order. Please unlock it first."
msgstr ""
#. module: sale
#. odoo-python
#: code:addons/sale/models/sale_order.py:0
#, python-format
msgid "You cannot change the pricelist of a confirmed order !"
msgstr ""
#. module: sale
#. odoo-python
#: code:addons/sale/models/product_product.py:0
+5
View File
@@ -786,6 +786,11 @@ class SaleOrder(models.Model):
]
return super().copy_data(default)
def write(self, values):
if 'pricelist_id' in values and any(so.state == 'sale' for so in self):
raise UserError(_("You cannot change the pricelist of a confirmed order !"))
return super().write(values)
@api.ondelete(at_uninstall=False)
def _unlink_except_draft_or_cancel(self):
for order in self: