[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:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user