Skip to content
Snippets Groups Projects
Commit 2ed464bc authored by Andrea Grazioso (agr-odoo)'s avatar Andrea Grazioso (agr-odoo)
Browse files

[FIX] account,hr_expense: double base line amount


Create an expense sheet (report)
Add 2+ expenses with 10% included tax to the same employee
Approve expenses and post journal entries
Bill will be created
Go to the tax report
Group by "Tax > Account" or "Account > Tax"

Issue: Bill line will have the tax basis calculated incorrectly
This occurs because the bill will have 2 separate tax line and the query
 does not handle this case

opw-3510371

closes odoo/odoo#136339

Signed-off-by: default avatarLaurent Smet (las) <las@odoo.com>
parent 58feb45c
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,11 @@ class AccountMoveLine(models.Model):
tables, where_clause, where_params = query.get_sql()
return self._get_query_tax_details(tables, where_clause, where_params, fallback=fallback)
@api.model
def _get_extra_query_base_tax_line_mapping(self):
#TO OVERRIDE
return ''
@api.model
def _get_query_tax_details(self, tables, where_clause, where_params, fallback=True):
""" Create the tax details sub-query based on the orm domain passed as parameter.
......@@ -81,6 +86,8 @@ class AccountMoveLine(models.Model):
fallback_query = ''
fallback_params = []
extra_query_base_tax_line_mapping = self._get_extra_query_base_tax_line_mapping()
return f'''
/*
As example to explain the different parts of the query, we'll consider a move with the following lines:
......@@ -185,6 +192,7 @@ class AccountMoveLine(models.Model):
OR (base_line.analytic_distribution IS NULL AND account_move_line.analytic_distribution IS NULL)
OR base_line.analytic_distribution = account_move_line.analytic_distribution
)
{extra_query_base_tax_line_mapping}
LEFT JOIN affecting_base_tax_ids tax_line_tax_ids ON tax_line_tax_ids.id = account_move_line.id
JOIN affecting_base_tax_ids base_line_tax_ids ON base_line_tax_ids.id = base_line.id
WHERE account_move_line.tax_repartition_line_id IS NOT NULL
......
......@@ -57,3 +57,6 @@ class AccountMoveLine(models.Model):
result.setdefault('extra_context', {})
result['extra_context']['force_price_include'] = True
return result
def _get_extra_query_base_tax_line_mapping(self):
return ' AND (base_line.expense_id IS NULL OR account_move_line.expense_id = base_line.expense_id)'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment