From 0c301855ea8e9cbc2afc1feb073f44620e3dd7e0 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Tue, 28 Feb 2023 15:10:45 +0000 Subject: [PATCH] [FIX] stock: prevent updating picking locations with move lines Since #91640, the locations on stock picking are editable except in `done` state. This can leads to misunderstanding if some stock move lines are already created. The locations on stock picking act as default values for stock move/ stock move lines. Validating a picking will always use the location set on stock move lines even if those ones differ from the picking. This commit adds a simple error message in to address this situation. Close #113486 opw-3148993 closes odoo/odoo#114868 X-original-commit: 3eeab703f4e36723eae6005cf4b966f20f1e62dd Signed-off-by: Arnold Moyaux (arm) Signed-off-by: William Henrotin (whe) --- addons/stock/i18n/stock.pot | 7 +++++++ addons/stock/models/stock_picking.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index fdb4d83bf8c..eba81dd2ad1 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -9318,6 +9318,13 @@ msgstr "" msgid "You may only return one picking at a time." msgstr "" +#. module: stock +#. odoo-python +#: code:addons/stock/model/stock_picking.py:0 +#, python-format +msgid " You might want to update the locations of this transfer's operations " +msgstr "" + #. module: stock #. odoo-python #: code:addons/stock/models/stock_picking.py:0 diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 1911560aa6a..45a1e2562e4 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -757,6 +757,12 @@ class Picking(models.Model): "location_id": self.location_id, "location_dest_id": self.location_dest_id }) + if any(line.reserved_qty or line.qty_done for line in self.move_ids.move_line_ids): + return {'warning': { + 'title': 'Locations to update', + 'message': _("You might want to update the locations of this transfer's operations") + } + } @api.model_create_multi def create(self, vals_list):