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: _amount_all

View 17.0 View 20.0
Inputs Method Outputs
  • order_line
  • company_id
  • company_id.tax_calculation_rounding_method
  • currency_id
  • amount_untaxed
  • amount_tax
  • company_id.currency_id
+ AccountTax = self.env['account.tax']
for order in self:
            order_lines = order.order_line.filtered(lambda x: not x.display_type)
- 
-             if order.company_id.tax_calculation_rounding_method == 'round_globally':
-                 tax_results = self.env['account.tax']._compute_taxes([
-                     line._convert_to_tax_base_line_dict()
-                     for line in order_lines
-                 ])
-                 totals = tax_results['totals']
-                 amount_untaxed = totals.get(order.currency_id, {}).get('amount_untaxed', 0.0)
-                 amount_tax = totals.get(order.currency_id, {}).get('amount_tax', 0.0)
-             else:
-                 amount_untaxed = sum(order_lines.mapped('price_subtotal'))
-                 amount_tax = sum(order_lines.mapped('price_tax'))
- 
-             if order.currency_id.compare_amounts(order.amount_untaxed, amount_untaxed):
-                 order.amount_untaxed = amount_untaxed
-             order.amount_tax = amount_tax
-             order.amount_total = order.amount_untaxed + order.amount_tax
+             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,
+             )
+             order.amount_untaxed = tax_totals['base_amount_currency']
+             order.amount_tax = tax_totals['tax_amount_currency']
+             order.amount_total = tax_totals['total_amount_currency']
+             order.amount_total_cc = tax_totals['total_amount']
  • amount_untaxed
  • amount_tax
  • amount_total
  • amount_total_cc

Back to entity