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

Compute Method: _compute_tax_totals

View 17.0 View 20.0
Inputs Method Outputs
  • order_line
  • currency_id
  • company_id
  • company_id.currency_id
  • company_currency_id
  • amount_total_cc
+ AccountTax = self.env['account.tax']
for order in self:
+             if not order.company_id:
+                 order.tax_totals = False
+                 continue
            order_lines = order.order_line.filtered(lambda x: not x.display_type)
-             order.tax_totals = self.env['account.tax']._prepare_tax_totals(
-                 [x._convert_to_tax_base_line_dict() for x in order_lines],
-                 order.currency_id or order.company_id.currency_id,
+             base_lines = [line._prepare_base_line_for_taxes_computation() for line in order_lines]
+             AccountTax._add_tax_details_in_base_lines(base_lines, order.company_id)
+             AccountTax._round_base_lines_tax_details(base_lines, order.company_id)
+             tax_totals = AccountTax._get_tax_totals_summary(
+                 base_lines=base_lines,
+                 currency=order.currency_id or order.company_id.currency_id,
+                 company=order.company_id,
            )
+             if order.currency_id != order.company_currency_id:
+                 tax_totals['amount_total_cc'] = f"({formatLang(self.env, order.amount_total_cc, currency_obj=order.company_currency_id)})"
+             order.tax_totals = tax_totals
  • tax_totals

Back to entity