diff --git a/addons/mrp/models/product.py b/addons/mrp/models/product.py index bb44bc97f0836b216469369ada316085d37c8d3c..8982320306eecded1eaae79a9ae1e6a68443b600 100644 --- a/addons/mrp/models/product.py +++ b/addons/mrp/models/product.py @@ -144,7 +144,7 @@ class ProductProduct(models.Model): # products have 0 qty available. continue uom_qty_per_kit = bom_line_data['qty'] / bom_line_data['original_qty'] - qty_per_kit = bom_line.product_uom_id._compute_quantity(uom_qty_per_kit, bom_line.product_id.uom_id, raise_if_failure=False) + qty_per_kit = bom_line.product_uom_id._compute_quantity(uom_qty_per_kit, bom_line.product_id.uom_id, round=False, raise_if_failure=False) if not qty_per_kit: continue component_res = qties.get(component.id, { diff --git a/addons/mrp/tests/test_bom.py b/addons/mrp/tests/test_bom.py index bfa47231ca3ae1167fa7bdcab03aacd56186b942..28592af6b5cd7dc669c9344e2691de102536fcaf 100644 --- a/addons/mrp/tests/test_bom.py +++ b/addons/mrp/tests/test_bom.py @@ -294,6 +294,37 @@ class TestBoM(TestMrpCommon): kit_product_qty, _, _ = (self.product_7_3 + self.product_2 + self.product_3).mapped("qty_available") self.assertEqual(kit_product_qty, 2) + def test_14_bom_kit_qty_multi_uom(self): + uom_dozens = self.env.ref('uom.product_uom_dozen') + uom_unit = self.env.ref('uom.product_uom_unit') + product_unit = self.env['product.product'].create({ + 'name': 'Test units', + 'type': 'product', + 'uom_id': uom_unit.id, + }) + product_dozens = self.env['product.product'].create({ + 'name': 'Test dozens', + 'type': 'product', + 'uom_id': uom_dozens.id, + }) + + self.env['mrp.bom'].create({ + 'product_tmpl_id': product_unit.product_tmpl_id.id, + 'product_uom_id': self.uom_unit.id, + 'product_qty': 1.0, + 'type': 'phantom', + 'bom_line_ids': [ + (0, 0, { + 'product_id': product_dozens.id, + 'product_qty': 1, + 'product_uom_id': uom_unit.id, + }) + ] + }) + location = self.env.ref('stock.stock_location_stock') + self.env['stock.quant']._update_available_quantity(product_dozens, location, 1.0) + self.assertEqual(product_unit.qty_available, 12.0) + def test_20_bom_report(self): """ Simulate a crumble receipt with mrp and open the bom structure report and check that data insde are correct.