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

Module: Account Invoice Margin

Entity: account.move.line

Compute Method: _compute_purchase_price

Inputs Method Outputs
  • move_id
  • product_uom_id
  • product_id
  • product_id.uom_id
for line in self:
            if not line.move_id.is_invoice():
                continue
            if line.move_id.is_sale_document():
                purchase_price = line._get_purchase_price()
                if line.product_uom_id != line.product_id.uom_id:
                    purchase_price = line.product_id.uom_id._compute_price(
                        purchase_price, line.product_uom_id
                    )
                move = line.move_id
                company = move.company_id or self.env.company
                line.purchase_price = company.currency_id._convert(
                    purchase_price,
                    move.currency_id,
                    company,
                    move.invoice_date or fields.Date.today(),
                    round=False,
                )
            else:
                line.purchase_price = 0.0

Back to entity