Skip to content
Snippets Groups Projects
user avatar
Touati Djamel (otd) authored
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#101004

X-original-commit: 9ec7aa9b
Signed-off-by: default avatarArnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: default avatarDjamel Touati (otd) <otd@odoo.com>
43ba9e32
History

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials