-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TA#72114 [16.0][MIG] hr_expense_tax_adjustment #236
base: 16.0
Are you sure you want to change the base?
Conversation
expense_id = fields.Many2one( | ||
"hr.expense", "Expense", required=True, ondelete="cascade", index=True | ||
) | ||
amount = fields.Float("Amount", required=True, digits=dp.get_precision("Account")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lanto-razafindrabe No need to use dp.get_precision anymore
we can use directly digits="Product Price" see here
account_id = fields.Many2one( | ||
"account.account", "Account", required=True, ondelete="restrict" | ||
) | ||
tax_id = fields.Many2one("account.tax", "Tax", required=True, ondelete="restrict") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lanto-razafindrabe
We need to add a new field company_id related to expense_id.company_id then add a check_company=True to the tax_id field. We can also add a domain to select only company taxes.
if self.quantity and self.unit_amount and self.tax_ids: | ||
self._setup_tax_lines() | ||
else: | ||
self.tax_line_ids = self.env["hr.expense.tax"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can simply set self.tax_line_ids to False
|
||
def _setup_tax_lines(self): | ||
"""Setup the taxes on the expense.""" | ||
self.tax_line_ids = self.env["hr.expense.tax"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont need to initiate self.tax_line_ids
self.tax_line_ids = self.env["hr.expense.tax"] | ||
|
||
currency = self.currency_id or self.company_id.currency_id | ||
taxes = self.tax_ids.with_context(round=True).compute_all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we can use directly self.tax_ids without compute_all
self.tax_ids is computed in V16 so we don't need to call compute_all
https://github.com/odoo/odoo/blob/16.0/addons/hr_expense/models/hr_expense.py#L67
https://github.com/odoo/odoo/blob/16.0/addons/hr_expense/models/hr_expense.py#L205
) | ||
tax_amount = sum(line.amount for line in expense.tax_line_ids) | ||
|
||
expense.untaxed_amount = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lanto-razafindrabe @rivo2302
In V16 untaxed_amount is calculated using another method "_compute_amount_tax()"
The method "_compute_amount" is only used to calculate "total_amount"
No description provided.