Skip to content

Commit

Permalink
[FIX] mrp: give default value when precision rounding value is zero
Browse files Browse the repository at this point in the history
The traceback arises when the user removes the 'product' from 'stock.move'
and try to add the product in 'mrp.production'.

To reproduce this issue:

1) Install 'MRP'
2) Create a new record for 'Manufacturing Order'
3) First add a line in 'Components'
4) Remove the 'product_id' from component
5) Now try to add 'Product' in mrp

Error:-"AssertionError: precision_rounding must be positive, got 0.0"

on the '_compute_state' method when the state is in 'draft' and
the user added a line in 'move_raw_ids'.

In this case, precision_rounding is getting value from
'product_uom.rounding' or 'product_id.uom_id.rounding' through 'move_raw_ids'.

See:- https://github.com/odoo/odoo/blob/10e0ac377cc235d81819eaa2a4ec2b6a60fffd70/addons/mrp/models/mrp_production.py#L478-#L479

When the user removed 'product_id' from 'move_raw_ids', 'precision_rounding'
will be '0.00'. Which leads to the above traceback.

Applying this commit will resolve the issue by giving a default value of '0.01',
when the 'precision_rounding' value is '0.00'.

sentry-4220927307

closes odoo#137904

X-original-commit: 5c238bb
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
Signed-off-by: Altaf Shaik (alsh) <alsh@odoo.com>
  • Loading branch information
alsh-odoo committed Oct 9, 2023
1 parent 403553a commit d1b0ab3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/mrp/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def _compute_state(self):
production.state = 'progress'
elif production.product_uom_id and not float_is_zero(production.qty_producing, precision_rounding=production.product_uom_id.rounding):
production.state = 'progress'
elif any(not float_is_zero(move.quantity_done, precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding) for move in production.move_raw_ids):
elif any(not float_is_zero(move.quantity_done, precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding) for move in production.move_raw_ids if move.product_id):
production.state = 'progress'

@api.depends('bom_id', 'product_id', 'product_qty', 'product_uom_id')
Expand Down

0 comments on commit d1b0ab3

Please sign in to comment.