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

Module: Purchase

Entity: purchase.order.line

Compute Method: _compute_amount

View 17.0 View 20.0
Inputs Method Outputs
  • company_id
  • price_total
  • price_subtotal
+ AccountTax = self.env['account.tax']
for line in self:
-             tax_results = self.env['account.tax']._compute_taxes([line._convert_to_tax_base_line_dict()])
-             totals = next(iter(tax_results['totals'].values()))
-             amount_untaxed = totals['amount_untaxed']
-             amount_tax = totals['amount_tax']
- 
-             line.update({
-                 'price_subtotal': amount_untaxed,
-                 'price_tax': amount_tax,
-                 'price_total': amount_untaxed + amount_tax,
-             })
+             company = line.company_id or self.env.company
+             base_line = line._prepare_base_line_for_taxes_computation()
+             AccountTax._add_tax_details_in_base_line(base_line, company)
+             AccountTax._round_base_lines_tax_details([base_line], company)
+             line.price_subtotal = base_line['tax_details']['total_excluded_currency']
+             line.price_total = base_line['tax_details']['total_included_currency']
+             line.price_tax = line.price_total - line.price_subtotal
+             line.non_deductible_tax = sum(
+                 tax_data['tax_amount_currency'] * tax_data['tax'].non_deductible_amount
+                 for tax_data in base_line['tax_details']['taxes_data']
+             )
  • price_subtotal
  • price_total
  • price_tax
  • non_deductible_tax

Back to entity