From 48fceb225333f3cd501ddd9b810e4e4a30a95c81 Mon Sep 17 00:00:00 2001 From: yhu-odoo Date: Wed, 11 Jan 2023 12:44:04 +0000 Subject: [PATCH] [FIX] stock: prevent change cancelled move After unlock a picking/MO, it's possible to change the qty_done of a cancelled move. This change won't have any result on product's stock. In this commit, we raise an error when user changing cancelled moves. We advise user to create a new line instead. Task-3116125 closes odoo/odoo#111910 X-original-commit: c6c3e5984c3fa0fc1810ae490bd4ce10390eebd8 Signed-off-by: Arnold Moyaux (arm) Signed-off-by: Tiffany Chang --- addons/stock/i18n/stock.pot | 7 +++++++ addons/stock/models/stock_move.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index 7f348c16a60..fdb4d83bf8c 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -9117,6 +9117,13 @@ msgid "" "in order to reverse the moves which took place." msgstr "" +#. module: stock +#. odoo-python +#: code:addons/stock/models/stock_move.py:0 +#, python-format +msgid "You cannot change a cancelled stock move, create a new line instead." +msgstr "" + #. module: stock #. odoo-python #: code:addons/stock/models/stock_picking.py:0 diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index dc40c2b9a68..29b1e0ebd97 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -669,6 +669,8 @@ Please change the quantity done or the rounding precision of your unit of measur # messages according to the state of the stock.move records. receipt_moves_to_reassign = self.env['stock.move'] move_to_recompute_state = self.env['stock.move'] + if 'quantity_done' in vals and any(move.state == 'cancel' for move in self): + raise UserError(_('You cannot change a cancelled stock move, create a new line instead.')) if 'product_uom' in vals and any(move.state == 'done' for move in self): raise UserError(_('You cannot change the UoM for a stock move that has been set to \'Done\'.')) if 'product_uom_qty' in vals: