diff options
| author | Arnold Moyaux <arm@odoo.com> | 2019-07-01 07:52:50 +0000 |
|---|---|---|
| committer | Arnold Moyaux <arm@odoo.com> | 2019-07-15 11:52:47 +0000 |
| commit | ccbd6712f6f2797a00aa165ded3292d355fcc5a0 (patch) | |
| tree | 65ed567a8c556278fb8e657e46c38a8b7327b59d /addons/mrp/wizard | |
| parent | d9b7cc7ab7ae7ee759c9931be20361c2348d2753 (diff) | |
[FIX] mrp: MO change the quantity to 0
Usecase to reproduce:
- Create a MO for 5 final units
- Reserve all the components
- Produce 3 units
- Post Inventory (debug mode)
- Edit/Unlock
- Edit a line to consume to an arbitrary amount of quantity
- Change the product qty and set it to 3.
At this point, the reserved quantity and the quantity to consume
still the same than intialy even if the final quantity was updated.
- Mark as done
Then a move is marked as done withtout quantity done and still have
reserved quantity.
It happens because the _update_raw_move function do nothing if the
new quantity to consume is equals to 0.
The arguments returns in _update_raw_move still exists for override
but are not used by the chang_prod_qty method. It's not possible to
cancel the move and then find its parents in order to log the activity.
opw-2023653
closes odoo/odoo#34471
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons/mrp/wizard')
| -rw-r--r-- | addons/mrp/wizard/change_production_qty.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py index b92616c9a50..ff7439f3d12 100644 --- a/addons/mrp/wizard/change_production_qty.py +++ b/addons/mrp/wizard/change_production_qty.py @@ -54,15 +54,22 @@ class ChangeProductionQty(models.TransientModel): boms, lines = production.bom_id.explode(production.product_id, factor, picking_type=production.bom_id.picking_type_id) documents = {} for line, line_data in lines: - move, old_qty, new_qty = production._update_raw_move(line, line_data) + move = production.move_raw_ids.filtered(lambda x: x.bom_line_id.id == line.id and x.state not in ('done', 'cancel')) + if move: + old_qty = move[0].product_uom_qty + else: + old_qty = 0 iterate_key = production._get_document_iterate_key(move) if iterate_key: - document = self.env['stock.picking']._log_activity_get_documents({move: (new_qty, old_qty)}, iterate_key, 'UP') + document = self.env['stock.picking']._log_activity_get_documents({move: (line_data['qty'], old_qty)}, iterate_key, 'UP') for key, value in document.items(): if documents.get(key): documents[key] += [value] else: documents[key] = [value] + + production._update_raw_move(line, line_data) + production._log_manufacture_exception(documents) operation_bom_qty = {} for bom, bom_data in boms: |
