Skip to content
Browse files

[FIX] sale_mrp: BOM selection for COGS

- Create the FIFO & Automated products:
  Kit ABC: 2 variants, e.g. Black and White, invoice on delivered qty
  Kit A
  Kit B
  Kit C
- Create the BOM for the variants of Kit ABC, in this order:
  Black: 1 unit of Kit A and 1 unit of Kit B
  White: 1 unit of Kit A and 1 unit of Kit C
- Receive the components
  Kit A: 10 USD
  Kit B: 12 USD
  Kit C: 13 USD
- Create a SO for Kit ABC (Black)
- Validate the picking, create and validate invoice

The COGS is incorrect: the amount is 23 instead of 22.

This happens because the BOM selected is always the first BOM of the
product template instead of the product-specific BOM.

We select the BOM the same way it is done when it is exploded in:

Note that if the BOM changed between picking creation and invoice
validation, it will fail.


closes #43266

X-original-commit: 7714f7c
Signed-off-by: Nicolas Martinelli (nim) <>
Co-authored-by: Nicolas Martinelli <>
  • Loading branch information
loan181 and nim-odoo committed Jan 9, 2020
1 parent fc85fd0 commit c72af0866bb2c95ccfa19010d14a85746150b999
Showing with 1 addition and 1 deletion.
  1. +1 −1 addons/sale_mrp/models/
@@ -92,7 +92,7 @@ def _get_anglo_saxon_price_unit(self):
# Go through all the moves and do nothing until you get to qty_done
# Beyond qty_done we need to calculate the average of the price_unit
# on the moves we encounter.
bom = s_line.product_id.product_tmpl_id.bom_ids and s_line.product_id.product_tmpl_id.bom_ids[0]
bom = self.env[''].sudo()._bom_find(product=s_line.product_id,
if bom.type == 'phantom':
average_price_unit = 0
components = s_line._get_bom_component_qty(bom)

0 comments on commit c72af08

Please sign in to comment.
You can’t perform that action at this time.