Skip to content
Snippets Groups Projects
Commit ea9fdac3 authored by Touati Djamel (otd)'s avatar Touati Djamel (otd)
Browse files

[FIX] mrp_account, sale_mrp: wrong kit cost after so confirmation

Steps to reproduce the bug:
- Create a storable product “B1”:
    - Costing Method: average
    - With BOM:
        - BOM Type: Kit
        - Components:
            - 3 units of “C1” (cost c1 = $2)
- Go to the “B1” product form:
    - Click on “Compute Price from BOM”
    - Cost = 3 * $2 = $6

- Create a storable product A1:
    - Costing Method: average
    - BOM
        - BOM Type: Kit
        - Components:
            - 2 units of B1

- Go to the “A1” product form:
    - Click on “Compute Price from BOM”
    So: 1 unit of A1 → 2 units of B1 → 3 units of C1
    - Cost = (2 * 3 * $2) = $12

- Create a SO:
    - Add 1 unit of “A1”
    - save
    - cost(`purchase_price`) = $12
    - Confirm the SO
    - The cost is recomputed and becomes = $6

Problem:
When the SO is created and the product “A1” is added, the cost is
retrieved from the product: https://github.com/odoo/odoo/blob/14.0/addons/sale_margin/models/sale_order.py#L27

But when the SO is confirmed, a picking is created, therefore the
cost is recomputed: https://github.com/odoo/odoo/blob/14.0/addons/sale_stock_margin/models/sale_order_line.py#L18



So The `_compute_average_price` function is called, in which a loop is
made for each move related to the `sale.order.line`, but the
`bom_line.product_qty` is used for each component (in this case the qty
necessary of the product `C1 ` to make a single unit of `B1`, but this
is not multiplied by the number of units needed to be used in the
parent's bom_line

opw-2971248

closes odoo/odoo#100126

Signed-off-by: default avatarArnold Moyaux (arm) <arm@odoo.com>
parent 7d33eea1
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment