[FIX] mrp: fix uom conversion in bom kit
no need to make rounding during computing qty_available STEPS (see the test): * create product with uom dozens * create product with uom units * create bom kit to convert one to another * set qty on hand to 1 for product dozens * check qty for product units BEFORE: qty=11 AFTER: qty=12 --- opw-2632782 closes odoo/odoo#76242 X-original-commit: 26b28408d8970baa8cbf59ffaff90cab1e579410 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
@@ -185,7 +185,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, {
|
||||
|
||||
@@ -359,6 +359,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.
|
||||
|
||||
Reference in New Issue
Block a user