summaryrefslogtreecommitdiff
path: root/addons/hr_expense/tests
diff options
context:
space:
mode:
authorLaurent Smet <las@odoo.com>2021-01-11 08:26:28 +0000
committeroco-odoo <oco@odoo.com>2021-01-15 13:52:59 +0000
commit4e8581b6846ef8ee4601c994b0d586734a4fe117 (patch)
treeec5aa8cefd568976ce7d879285506eff006bc3c7 /addons/hr_expense/tests
parent603dbbe7a784c23b87682655963e82a42137d84c (diff)
[IMP] account: introduce a new field on move lines to avoid inverting tax tags
The sign of tax tags sometimes could get inverted explicitly. It typically happened for misc operations, so : - manual entries - CABA entries - writeoffs created from the reconciliation widget We had to do things this way in stable to fix those use cases, but it's not ideal, as the tags shown to the user were inverted, so it was a bit confusing, as one would have expected to see the exact same tags as on tax configuration. We fix that by using a boolean field on account.move.line telling whether or not the sign must be inverted. This allows keeping the same tags as in the tax config, and simplifies the computation of the tax report's multiplicator, making the overall model more intuitive for both user and developper. Task 2363287 closes #62536 closes odoo/odoo#64558 Related: odoo/enterprise#15031 Related: odoo/upgrade#1983 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com> Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/hr_expense/tests')
-rw-r--r--addons/hr_expense/tests/test_expenses.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/addons/hr_expense/tests/test_expenses.py b/addons/hr_expense/tests/test_expenses.py
index f2d1fd86676..9cf10b651bf 100644
--- a/addons/hr_expense/tests/test_expenses.py
+++ b/addons/hr_expense/tests/test_expenses.py
@@ -138,3 +138,33 @@ class TestExpenses(TestExpenseCommon):
'currency_id': self.company_data['currency'].id,
},
])
+
+ def test_expenses_with_tax_and_lockdate(self):
+ ''' Test creating a journal entry for multiple expenses using taxes. A lock date is set in order to trigger
+ the recomputation of the taxes base amount.
+ '''
+ self.env.company.tax_lock_date = '2020-02-01'
+
+ expense = self.env['hr.expense.sheet'].create({
+ 'name': 'Expense for John Smith',
+ 'employee_id': self.expense_employee.id,
+ 'accounting_date': '2020-01-01'
+ })
+
+ for i in range(2):
+ expense_line = self.env['hr.expense'].create({
+ 'name': 'Car Travel Expenses',
+ 'employee_id': self.expense_employee.id,
+ 'product_id': self.product_a.id,
+ 'unit_amount': 350.00,
+ 'tax_ids': [(6, 0, [self.tax_purchase_a.id])],
+ 'sheet_id': expense.id,
+ 'analytic_account_id': self.analytic_account_1.id,
+ })
+ expense_line._onchange_product_id_date_account_id()
+
+ expense.action_submit_sheet()
+ expense.approve_expense_sheets()
+
+ # Assert not "Cannot create unbalanced journal entry" error.
+ expense.action_sheet_move_create()