[FIX] mrp: Handle kit with BoM having qty != 1
Use case: - Create a Kit BoM with finished qty to 5 consuming 10 components - Do a sale order for 3 units (3/5 of BoM) - Update the sale order line to 4 units Current behavior: The delivery has a huge amount to deliver Expected: The delivery is for 8 units It happens because the method `_compute_kit_quantities` always expect a BoM for 1 units. `bom_line_data['original_qty']` always contains the number of times the BoM will be needed and not the quantity of finished products. In order to have the number of component by unit of finished product we have to introduce the BoM quantity in the formula closes odoo/odoo#160149 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
@@ -545,6 +545,7 @@ class StockMove(models.Model):
|
||||
:return: The quantity delivered or received
|
||||
"""
|
||||
qty_ratios = []
|
||||
kit_qty = kit_qty / kit_bom.product_qty
|
||||
boms, bom_sub_lines = kit_bom.explode(product_id, kit_qty)
|
||||
for bom_line, bom_line_data in bom_sub_lines:
|
||||
# skip service since we never deliver them
|
||||
@@ -559,8 +560,8 @@ class StockMove(models.Model):
|
||||
# We compute the quantities needed of each components to make one kit.
|
||||
# Then, we collect every relevant moves related to a specific component
|
||||
# to know how many are considered delivered.
|
||||
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, round=False)
|
||||
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 / kit_bom.product_qty, bom_line.product_id.uom_id, round=False)
|
||||
if not qty_per_kit:
|
||||
continue
|
||||
incoming_moves = bom_line_moves.filtered(filters['incoming_moves'])
|
||||
|
||||
Reference in New Issue
Block a user