Files
odoo_source/addons/hr_expense/tests/common.py
T
jbm-odoo ec07e72845 [IMP] base,*: Reorganize access rights groups
Purpose
=======

Access group terminology is missleading. Yous have to be manager to administrate
an application. This task consists to rename groups to be understandable for everyone.

Groups should be reorganised on the users form to be more explicit.

Specification
=============

1/ Rename 'Manager' to 'Administrator' in users groups.
2/ Define a hierarchy on access groups by using the category_id in the manifests
   A category 'Operations/Project' will create a category Project with a parent
   category 'Operations', and something smart is already developed (in modules/db.py)
   to avoid duplicating categories.
3/ Add a group in expenses to be able to approve expenses reports for my team.
4/ Add a group in timesheets to be able to approve timesheets for my team.
5/ Remove partially the useless crap in ir_module_category_data.xml
6/ Sort access rights groups on users form according to its parent category

closes odoo/odoo#29362

Signed-off-by: "Yannick Tivisse (yti)" <yti@odoo.com>
2019-03-05 09:08:12 +00:00

123 lines
4.0 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.account.tests.account_test_no_chart import TestAccountNoChartCommon
class TestExpenseCommon(TestAccountNoChartCommon):
@classmethod
def setUpClass(cls):
super(TestExpenseCommon, cls).setUpClass()
cls.setUpUsers()
# The user manager is only expense manager
user_group_manager = cls.env.ref('hr_expense.group_hr_expense_manager')
cls.user_manager.write({
'groups_id': [(6, 0, [user_group_manager.id, cls.env.ref('base.group_user').id])],
})
# create employee
cls.employee = cls.env['hr.employee'].create({
'name': 'Johnny Employee',
'user_id': cls.user_employee.id,
'address_home_id': cls.user_employee.partner_id.id,
'address_id': cls.user_employee.partner_id.id,
})
# Create tax
cls.tax = cls.env['account.tax'].create({
'name': 'Expense 10%',
'amount': 10,
'amount_type': 'percent',
'type_tax_use': 'purchase',
'price_include': True,
})
# Create analytic account
cls.analytic_account = cls.env['account.analytic.account'].create({
'name': 'Test Analytic Account for Expenses',
})
# Expense reports
cls.journal = cls.env['account.journal'].create({
'name': 'Purchase Journal - Test',
'code': 'HRTPJ',
'type': 'purchase',
'company_id': cls.env.user.company_id.id,
})
cls.expense_sheet = cls.env['hr.expense.sheet'].create({
'name': 'Expense for Johnny Employee',
'employee_id': cls.employee.id,
'journal_id': cls.journal.id,
})
cls.expense_sheet2 = cls.env['hr.expense.sheet'].create({
'name': 'Second Expense for Johnny Employee',
'employee_id': cls.employee.id,
'journal_id': cls.journal.id,
})
Users = cls.env['res.users'].with_context(no_reset_password=True)
# Find Employee group
group_employee_id = cls.env.ref('base.group_user').id
cls.user_emp2 = Users.create({
'name': 'Superboy Employee',
'login': 'superboy',
'email': 'superboy@example.com',
'groups_id': [(6, 0, [group_employee_id])]
})
cls.user_officer = Users.create({
'name': 'Batman Officer',
'login': 'batman',
'email': 'batman.hero@example.com',
'groups_id': [(6, 0, [group_employee_id, cls.env.ref('hr_expense.group_hr_expense_team_approver').id])]
})
cls.emp_emp2 = cls.env['hr.employee'].create({
'name': 'Superboy',
'user_id': cls.user_emp2.id,
})
cls.emp_officer = cls.env['hr.employee'].create({
'name': 'Batman',
'user_id': cls.user_officer.id,
})
cls.emp_manager = cls.env['hr.employee'].create({
'name': 'Superman',
'user_id': cls.user_manager.id,
})
cls.rd = cls.env['hr.department'].create({
'name': 'R&D',
'manager_id': cls.emp_officer.id,
'member_ids': [(6, 0, [cls.employee.id])],
})
cls.ps = cls.env['hr.department'].create({
'name': 'PS',
'manager_id': cls.emp_manager.id,
'member_ids': [(6, 0, [cls.emp_emp2.id])],
})
cls.uom_unit = cls.env.ref('uom.product_uom_unit').id
cls.uom_dozen = cls.env.ref('uom.product_uom_dozen').id
cls.product_1 = cls.env['product.product'].create({
'name': 'Batmobile repair',
'type': 'service',
'uom_id': cls.uom_unit,
'uom_po_id': cls.uom_unit,
})
cls.product_2 = cls.env['product.product'].create({
'name': 'Superboy costume washing',
'type': 'service',
'uom_id': cls.uom_unit,
'uom_po_id': cls.uom_unit,
})