Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Margins in Sales Orders

Entity: sale.order.line

Compute Method: _compute_purchase_price

Inputs Method Outputs
  • product_id
  • company_id
  • product_id.uom_id
  • product_id.standard_price
  • product_uom
  • product_id.cost_currency_id
for line in self:
            if not line.product_id:
                line.purchase_price = 0.0
                continue
            line = line.with_company(line.company_id)

            # Convert the cost to the line UoM
            product_cost = line.product_id.uom_id._compute_price(
                line.product_id.standard_price,
                line.product_uom,
            )

            line.purchase_price = line._convert_to_sol_currency(
                product_cost,
                line.product_id.cost_currency_id)

Back to entity