diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 9ef2252e3dc..f43838d75fd 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -817,7 +817,7 @@ class AccountTax(models.Model): if tax.include_base_amount: base = recompute_base(base, incl_fixed_amount, incl_percent_amount) incl_fixed_amount = incl_percent_amount = 0 - if tax.price_include: + if self._context.get('force_price_include', tax.price_include): if tax.amount_type == 'fixed': incl_fixed_amount += tax.amount elif tax.amount_type == 'percent': @@ -839,7 +839,10 @@ class AccountTax(models.Model): # took into account on the base amount except for 'division' tax: # (tax.amount_type == 'percent' && not tax.price_include) # == (tax.amount_type == 'division' && tax.price_include) - tax_amount = tax.with_context(force_price_include=False)._compute_amount(base, price_unit, quantity, product, partner) + # N.B: don't use the with_context if force_price_include already False in context + if 'force_price_include' not in self._context or self._context['force_price_include']: + tax = tax.with_context(force_price_include=False) + tax_amount = tax._compute_amount(base, price_unit, quantity, product, partner) if not round_tax: tax_amount = round(tax_amount, prec) else: diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index ef5a18ccafa..dc265156946 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -819,6 +819,7 @@ class AccountBankStatementLine(models.Model): whose value is the same as described in process_reconciliation except that ids are used instead of recordsets. """ AccountMoveLine = self.env['account.move.line'] + ctx = dict(self._context, force_price_include=False) for st_line, datum in zip(self, data): payment_aml_rec = AccountMoveLine.browse(datum.get('payment_aml_ids', [])) for aml_dict in datum.get('counterpart_aml_dicts', []): @@ -826,7 +827,7 @@ class AccountBankStatementLine(models.Model): del aml_dict['counterpart_aml_id'] if datum.get('partner_id') is not None: st_line.write({'partner_id': datum['partner_id']}) - st_line.process_reconciliation(datum.get('counterpart_aml_dicts', []), payment_aml_rec, datum.get('new_aml_dicts', [])) + st_line.with_context(ctx).process_reconciliation(datum.get('counterpart_aml_dicts', []), payment_aml_rec, datum.get('new_aml_dicts', [])) def fast_counterpart_creation(self): for st_line in self: diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index dba262922fe..09086ccb15c 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1194,7 +1194,7 @@ class AccountMoveLine(models.Model): taxes = self.env['account.tax'].browse(tax_ids) currency = self.env['res.currency'].browse(vals.get('currency_id')) partner = self.env['res.partner'].browse(vals.get('partner_id')) - res = taxes.with_context(round=True).compute_all(amount, + res = taxes.with_context(dict(self._context, round=True)).compute_all(amount, currency, 1, vals.get('product_id'), partner) # Adjust line amount if any tax is price_include if abs(res['total_excluded']) < abs(amount):