summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2020-02-19 16:34:54 +0000
committerArnold Moyaux <arm@odoo.com>2020-02-24 13:18:26 +0000
commitfd0937bdc786b47dfbb7b1785de750eecb2cc6ba (patch)
tree32e3de0ba8494e87f1ab47146a10f97d48924683
parenteb1207a7055227ce39daea886d1b79902706eb3a (diff)
[FIX] mrp: Quantities of components on MO
Steps to reproduce the bug: - Install Manufacturing - Go to General Settings/Inventory and tick Units of Measure - Create a product P (storable) with UOM kg - Create a Bill of Material for this product: e.g. 1 kg - Add a component C with UOM "kg", but in the BOM uses "g" - Create a MO for P, Mark as todo, Produce - Click on C to change the quantities (e.g. change the first line to 900 g) - Add a second line with 0.1 kg (as the uom of C is in kg, you are forced to set in kg) Bug: The strict consumption check is raised. It happens because the lines quantity done are not correctly converted in the same UoM opw:2181892 closes odoo/odoo#46103 X-original-commit: e385930f8687fc4051ddd375fe0551dba59a8750 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
-rw-r--r--addons/mrp/models/mrp_abstract_workorder.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/mrp/models/mrp_abstract_workorder.py b/addons/mrp/models/mrp_abstract_workorder.py
index 1af07bc81cf..636ee2d32b7 100644
--- a/addons/mrp/models/mrp_abstract_workorder.py
+++ b/addons/mrp/models/mrp_abstract_workorder.py
@@ -297,8 +297,11 @@ class MrpAbstractWorkorder(models.AbstractModel):
if self.consumption == 'strict':
for move in self.move_raw_ids:
lines = self._workorder_line_ids().filtered(lambda l: l.move_id == move)
- qty_done = sum(lines.mapped('qty_done'))
- qty_to_consume = sum(lines.mapped('qty_to_consume'))
+ qty_done = 0.0
+ qty_to_consume = 0.0
+ for line in lines:
+ qty_done += line.product_uom_id._compute_quantity(line.qty_done, line.product_id.uom_id)
+ qty_to_consume += line.product_uom_id._compute_quantity(line.qty_to_consume, line.product_id.uom_id)
rounding = self.product_uom_id.rounding
if float_compare(qty_done, qty_to_consume, precision_rounding=rounding) != 0:
raise UserError(_('You should consume the quantity of %s defined in the BoM. If you want to consume more or less components, change the consumption setting on the BoM.') % lines[0].product_id.name)