Skip to content

Commit

Permalink
[FIX] hr_Expense_excluded_tax
Browse files Browse the repository at this point in the history
  • Loading branch information
ps-tubtim committed Jul 17, 2023
1 parent e3879c3 commit 9cdb181
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion hr_expense_excluded_tax/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models


class HrExpense(models.Model):
Expand All @@ -10,3 +10,20 @@ class HrExpense(models.Model):
tax_ids = fields.Many2many(
domain="[('company_id', '=', company_id), ('type_tax_use', '=', 'purchase')]",
)

@api.depends("total_amount", "tax_ids", "currency_id")
def _compute_amount_tax(self):
"""Calculate untaxed_amount if the user selects
excluded tax in a product that has a cost"""
res = super()._compute_amount_tax()
for expense in self:
if expense.product_has_cost:
taxes = expense.tax_ids.compute_all(
expense.unit_amount,
expense.currency_id,
expense.quantity,
expense.product_id,
expense.employee_id.user_id.partner_id,
)
expense.untaxed_amount = taxes.get("total_excluded")
return res

0 comments on commit 9cdb181

Please sign in to comment.