From bcea427c02bd6a74bf19e310225be3e3a9581be1 Mon Sep 17 00:00:00 2001 From: sofiagvaladze Date: Thu, 23 Jun 2022 08:28:04 +0000 Subject: [PATCH] [IMP] hr_expense: use all taxes as price_included In expense flow the taxes are calculated as included in price. Prior, to guarantee it, we had domain - ('price_include', '=', True) on taxes. That could be inconvenient from user's point of view, as they first needed to define taxes with price_include = True. That led to users duplicating taxes between included/excluded just so that they could use taxes in expense. Now we force taxes to act like price_include = True. This way, user does not need to define taxes just for expense's purposes and still taxes will be calculated as it supposed to be - included in price. task - 2850882 closes odoo/odoo#94392 Signed-off-by: Kevin Baptiste --- addons/hr_expense/models/hr_expense.py | 6 +++--- addons/hr_expense/views/hr_expense_views.xml | 2 +- addons/hr_expense/wizard/hr_expense_split.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 279ba340d8f..2d7c173c5aa 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -76,7 +76,7 @@ class HrExpense(models.Model): quantity = fields.Float(required=True, states={'done': [('readonly', True)]}, digits='Product Unit of Measure', default=1) tax_ids = fields.Many2many('account.tax', 'expense_tax', 'expense_id', 'tax_id', compute='_compute_from_product_id_company_id', store=True, readonly=False, - domain="[('company_id', '=', company_id), ('type_tax_use', '=', 'purchase'), ('price_include', '=', True)]", string='Included taxes') + domain="[('company_id', '=', company_id), ('type_tax_use', '=', 'purchase')]", string='Included taxes') amount_tax = fields.Monetary(string='Tax amount in Currency', help="Tax amount in currency", compute='_compute_amount_tax', store=True, currency_field='currency_id') amount_tax_company = fields.Monetary('Tax amount', help="Tax amount in company currency", compute='_compute_total_amount_company', store=True, currency_field='company_currency_id') amount_residual = fields.Monetary(string='Amount Due', compute='_compute_amount_residual') @@ -187,7 +187,7 @@ class HrExpense(models.Model): def _get_taxes(self, price, quantity): self.ensure_one() - return self.tax_ids.compute_all(price_unit=price, currency=self.currency_id, quantity=quantity, product=self.product_id, partner=self.employee_id.user_id.partner_id) + return self.tax_ids.with_context(force_price_include=True).compute_all(price_unit=price, currency=self.currency_id, quantity=quantity, product=self.product_id, partner=self.employee_id.user_id.partner_id) @api.depends("sheet_id.account_move_id.line_ids") def _compute_amount_residual(self): @@ -621,7 +621,7 @@ Or send your receipts at - diff --git a/addons/hr_expense/wizard/hr_expense_split.py b/addons/hr_expense/wizard/hr_expense_split.py index 9a566552f8a..fbe94e224f4 100644 --- a/addons/hr_expense/wizard/hr_expense_split.py +++ b/addons/hr_expense/wizard/hr_expense_split.py @@ -41,7 +41,7 @@ class HrExpenseSplit(models.TransientModel): @api.depends('total_amount', 'tax_ids') def _compute_amount_tax(self): for split in self: - taxes = split.tax_ids.compute_all(price_unit=split.total_amount, currency=split.currency_id, quantity=1, product=split.product_id) + taxes = split.tax_ids.with_context(force_price_include=True).compute_all(price_unit=split.total_amount, currency=split.currency_id, quantity=1, product=split.product_id) split.amount_tax = taxes['total_included'] - taxes['total_excluded'] @api.depends('product_id')