[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) <arm@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
yhu-odoo
2023-02-06 10:18:51 +01:00
parent 75c6eda262
commit 48fceb2253
2 changed files with 9 additions and 0 deletions
+7
View File
@@ -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
+2
View File
@@ -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: