Skip to content
Permalink
Browse files

[FIX] stock: forbid to modify product on done move line

It happens that people modify the product on done stock.move.line
(it's not possible without customisation, at least allow to import or
to modify product and lot_id in the same view).

During the write on stock.move.line only the lot,locations,package and
owner are update on the quant. Not the product since it's not suppose to
be modify. It leads to a stock.move.line with a correct information but
a total mess on the quants with a lot updated and the previous product.
Since the product is not modified, the product on the quant and the
product on the lot linked to the same quant are different.

closes #43140

Task: 2119471
X-original-commit: 3ec96c3
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information
amoyaux committed Jan 2, 2020
1 parent 0755be9 commit b0c4a98dd8715c11a83d092a945fbd7aabc8fdf2
Showing with 9 additions and 0 deletions.
  1. +6 −0 addons/stock/i18n/stock.pot
  2. +3 −0 addons/stock/models/stock_move_line.py
@@ -6511,3 +6511,9 @@ msgstr ""
msgid "⇒ Set quantities to 0"
msgstr ""

#. module: stock
#: code:addons/stock/models/stock_move_line.py:223
#, python-format
msgid "Changing the product is only allowed in 'Draft' state."
msgstr ""

@@ -219,6 +219,9 @@ def write(self, vals):
if self.env.context.get('bypass_reservation_update'):
return super(StockMoveLine, self).write(vals)

if 'product_id' in vals and any(vals.get('state', ml.state) != 'draft' and vals['product_id'] != ml.product_id.id for ml in self):
raise UserError(_("Changing the product is only allowed in 'Draft' state."))

Quant = self.env['stock.quant']
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
# We forbid to change the reserved quantity in the interace, but it is needed in the

0 comments on commit b0c4a98

Please sign in to comment.
You can’t perform that action at this time.