[FIX] mrp: cancel move when click on Mark Done
[FIX] mrp: Manufacturing cost analysis report
Steps to reproduce the bug:
- Create a finished product P with a manufacturing BOM B
- Set two components on B C1 and C2
- Create a MO with P and process it(plan and produce it)
- Unlock the MO and set the consumed qty of C1 to 0
- Lock and click on Mark as Done
- Click on Cost Analysis
Bug:
C1 was displayed in the report with a qty = 1.0
Fine tuning of this commit: cb4afb263b
opw:2010912
closes odoo/odoo#34642
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
committed by
Goffin Simon
parent
a0fa785eb5
commit
fb1839fa17
@@ -667,8 +667,6 @@ class MrpProduction(models.Model):
|
||||
moves_to_do = order.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
|
||||
for move in moves_to_do.filtered(lambda m: m.product_qty == 0.0 and m.quantity_done > 0):
|
||||
move.product_uom_qty = move.quantity_done
|
||||
for move in moves_to_do.filtered(lambda m: float_is_zero(m.quantity_done, precision_rounding=m.product_uom.rounding)):
|
||||
move._action_cancel()
|
||||
moves_to_do._action_done()
|
||||
moves_to_do = order.move_raw_ids.filtered(lambda x: x.state == 'done') - moves_not_to_do
|
||||
order._cal_price(moves_to_do)
|
||||
@@ -695,6 +693,11 @@ class MrpProduction(models.Model):
|
||||
if wo.time_ids.filtered(lambda x: (not x.date_end) and (x.loss_type in ('productive', 'performance'))):
|
||||
raise UserError(_('Work order %s is still running') % wo.name)
|
||||
self._check_lots()
|
||||
|
||||
# Cancel unfinished move
|
||||
move_to_cancel = self.move_raw_ids.filtered(lambda m: m.state not in ('done', 'cancel') and float_is_zero(m.quantity_done, precision_rounding=m.product_uom.rounding))
|
||||
move_to_cancel._action_cancel()
|
||||
|
||||
self.post_inventory()
|
||||
# Moves without quantity done are not posted => set them as done instead of canceling. In
|
||||
# case the user edits the MO later on and sets some consumed quantity on those, we do not
|
||||
|
||||
Reference in New Issue
Block a user