Skip to content

Commit

Permalink
[FIX] sale: forbid pricelist changes on confirmed orders
Browse files Browse the repository at this point in the history
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.

X-original-commit: dc7b75f
  • Loading branch information
Feyensv committed Mar 28, 2024
1 parent 10c579b commit f03c90a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/sale/i18n/sale.pot
Expand Up @@ -4833,6 +4833,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
Expand Down
2 changes: 2 additions & 0 deletions addons/sale/models/sale_order.py
Expand Up @@ -795,6 +795,8 @@ def _unlink_except_draft_or_cancel(self):
" You must first cancel it."))

def write(self, vals):
if 'pricelist_id' in vals and any(so.state == 'sale' for so in self):
raise UserError(_("You cannot change the pricelist of a confirmed order !"))
res = super().write(vals)
if vals.get('partner_id'):
self.filtered(lambda so: so.state in ('sent', 'sale')).message_subscribe(
Expand Down

0 comments on commit f03c90a

Please sign in to comment.