Files
odoo_source/addons/hr_expense/tests/common.py
T
william 96b5b6b515 [FIX] hr_expense: expenses should be tax included
During a refactoring [1], the behavior of having the taxes included in
the price for all expenses was broken/removed.
All the fields related to taxes are computed should be computed with the
correct context key when computing entries related to expenses. This is
preferred to adding the context key only when creating because it will
then keep the behavior even when editing the document.

task-3043252

[1]: https://github.com/odoo/odoo/commit/d8d47f9ff8554f4b39487fd2f13c153c7d6f958d

closes odoo/odoo#104746

X-original-commit: 6e944ac5fe108d5f2bc2d3f41ab547efd88a5ede
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2022-11-03 09:37:03 +01:00

58 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.mail.tests.common import mail_new_test_user
class TestExpenseCommon(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
group_expense_manager = cls.env.ref('hr_expense.group_hr_expense_manager')
cls.expense_user_employee = mail_new_test_user(
cls.env,
name='expense_user_employee',
login='expense_user_employee',
email='expense_user_employee@example.com',
notification_type='email',
groups='base.group_user',
company_ids=[(6, 0, cls.env.companies.ids)],
)
cls.expense_user_manager = mail_new_test_user(
cls.env,
name='Expense manager',
login='expense_manager_1',
email='expense_manager_1@example.com',
notification_type='email',
groups='base.group_user,hr_expense.group_hr_expense_manager',
company_ids=[(6, 0, cls.env.companies.ids)],
)
cls.expense_employee = cls.env['hr.employee'].create({
'name': 'expense_employee',
'user_id': cls.expense_user_employee.id,
'address_home_id': cls.expense_user_employee.partner_id.id,
'address_id': cls.expense_user_employee.partner_id.id,
})
# Allow the current accounting user to access the expenses.
cls.env.user.groups_id |= group_expense_manager
# Create analytic account
cls.analytic_plan = cls.env['account.analytic.plan'].create({'name': 'Plan Test', 'company_id': False})
cls.analytic_account_1 = cls.env['account.analytic.account'].create({
'name': 'analytic_account_1',
'plan_id': cls.analytic_plan.id,
})
cls.analytic_account_2 = cls.env['account.analytic.account'].create({
'name': 'analytic_account_2',
'plan_id': cls.analytic_plan.id,
})
# Ensure products can be expensed.
(cls.product_a + cls.product_b).write({'can_be_expensed': True})