diff --git a/addons/hr_expense/models/account_move_line.py b/addons/hr_expense/models/account_move_line.py index 6680057a171..bb9ca3613ab 100644 --- a/addons/hr_expense/models/account_move_line.py +++ b/addons/hr_expense/models/account_move_line.py @@ -34,15 +34,28 @@ class AccountMoveLine(models.Model): line.tax_key = frozendict(**line.tax_key, expense_id=line.expense_id.id) def _compute_all_tax(self): - super()._compute_all_tax() - for line in self: - if line.expense_id: - for key in list(line.compute_all_tax.keys()): - new_key = frozendict(**key, expense_id=line.expense_id.id) - line.compute_all_tax[new_key] = line.compute_all_tax.pop(key) + expense_lines = self.filtered('expense_id') + super(AccountMoveLine, expense_lines.with_context(force_price_include=True))._compute_all_tax() + super(AccountMoveLine, self - expense_lines)._compute_all_tax() + for line in expense_lines: + for key in list(line.compute_all_tax.keys()): + new_key = frozendict(**key, expense_id=line.expense_id.id) + line.compute_all_tax[new_key] = line.compute_all_tax.pop(key) + + def _compute_totals(self): + expenses = self.filtered('expense_id') + super(AccountMoveLine, expenses.with_context(force_price_include=True))._compute_totals() + super(AccountMoveLine, self - expenses)._compute_totals() def _compute_term_key(self): super()._compute_term_key() for line in self: if line.expense_id: line.term_key = line.term_key and frozendict(**line.term_key, expense_id=line.expense_id.id) + + def _convert_to_tax_base_line_dict(self): + result = super()._convert_to_tax_base_line_dict() + if self.move_id.expense_sheet_id: + result.setdefault('extra_context', {}) + result['extra_context']['force_price_include'] = True + return result diff --git a/addons/hr_expense/tests/common.py b/addons/hr_expense/tests/common.py index e88b0434e01..3604ed2d72a 100644 --- a/addons/hr_expense/tests/common.py +++ b/addons/hr_expense/tests/common.py @@ -55,6 +55,3 @@ class TestExpenseCommon(AccountTestInvoicingCommon): # Ensure products can be expensed. (cls.product_a + cls.product_b).write({'can_be_expensed': True}) - # Taxes on the products are included in price - (cls.product_a.supplier_taxes_id + cls.product_b.supplier_taxes_id).write({'price_include': True}) - cls.company_data['default_tax_purchase'].write({'price_include': True})