From 847b1e18f6fb26244623ff0670ab366441d7feff Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Wed, 18 May 2022 12:49:58 +0000 Subject: [PATCH] [IMP] account: Allow 'handle_price_included' taxes computation at the line level Task: 2555114 Part-of: odoo/odoo#91448 --- addons/account/models/account_tax.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index b6f4f540699..65b1a4ae931 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -702,6 +702,8 @@ class AccountTax(models.Model): partner=None, currency=None, product=None, taxes=None, price_unit=None, quantity=None, discount=None, account=None, analytic_account=None, analytic_tags=None, price_subtotal=None, is_refund=False, + handle_price_include=None, + extra_context=None, ): return { 'record': base_line, @@ -717,6 +719,8 @@ class AccountTax(models.Model): 'analytic_tags': analytic_tags or self.env['account.analytic.tag'], 'price_subtotal': price_subtotal or 0.0, 'is_refund': is_refund, + 'handle_price_include': handle_price_include, + 'extra_context': extra_context or {}, } @api.model @@ -791,7 +795,8 @@ class AccountTax(models.Model): :param base_lines: A list of python dictionaries created using the '_convert_to_tax_base_line_dict' method. :param tax_lines: A list of python dictionaries created using the '_convert_to_tax_line_dict' method. - :param handle_price_include: Manage the price-included taxes. + :param handle_price_include: Manage the price-included taxes. If None, use the 'handle_price_include' key + set on base lines. :param include_caba_tags: Manage tags for taxes being exigible on_payment. :return: A python dictionary containing: @@ -834,14 +839,20 @@ class AccountTax(models.Model): currency = line_vals['currency'] or self.env.company.currency_id if taxes: - taxes_res = taxes.compute_all( + + if handle_price_include is None: + manage_price_include = bool(line_vals['handle_price_include']) + else: + manage_price_include = handle_price_include + + taxes_res = taxes.with_context(**line_vals['extra_context']).compute_all( price_unit_after_discount, currency=currency, quantity=line_vals['quantity'], product=line_vals['product'], partner=line_vals['partner'], is_refund=line_vals['is_refund'], - handle_price_include=handle_price_include, + handle_price_include=manage_price_include, include_caba_tags=include_caba_tags, )