Files
odoo_source/addons/hr_payroll/tests/common.py
T
Yannick Tivisse 1684ec555d [IMP] hr_payroll: Manage multi company on payslips/contracts
Purpose
=======

Currently the payroll doens't manage the multi company

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

1/ Add ir.rules on hr.contract and hr.payslip to prevent users
   to access a record in another company.
2/ Add ir.rules on hr.payroll.structure to prevent users to access
   a record for another country.
3/ Remove company_id fields on models that doesn't require it, as
   hr.salary.rule.category.
4/ Make the accounting fields on the salary rules company dependent.
5/ Specify the country on the salary structures on the
   l10n_**_hr_payroll modules.
6/ Add demo data and modify the salary package tour.
7/ Make the car_atn and company_car_total_depreciated_costs fields
   compute_sudo=True, as one car can be assigned on several contract,
   for different companies

Closes #26866
Closes #25231
Closes #24683
Closes #23814
2019-01-21 12:33:03 +01:00

50 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import datetime, timedelta
from odoo.fields import Date
from odoo.tests.common import TransactionCase
class TestPayslipBase(TransactionCase):
def setUp(self):
super(TestPayslipBase, self).setUp()
# Some salary rules references
self.hra_rule_id = self.ref('hr_payroll.hr_salary_rule_houserentallowance1')
self.conv_rule_id = self.ref('hr_payroll.hr_salary_rule_convanceallowance1')
self.prof_tax_rule_id = self.ref('hr_payroll.hr_salary_rule_professionaltax1')
self.pf_rule_id = self.ref('hr_payroll.hr_salary_rule_providentfund1')
self.mv_rule_id = self.ref('hr_payroll.hr_salary_rule_meal_voucher')
# I create a new employee "Richard"
self.richard_emp = self.env['hr.employee'].create({
'name': 'Richard',
'gender': 'male',
'birthday': '1984-05-01',
'country_id': self.ref('base.be'),
'department_id': self.ref('hr.dep_rd')
})
# I create a salary structure for "Software Developer"
self.developer_pay_structure = self.env['hr.payroll.structure'].create({
'name': 'Salary Structure for Software Developer',
'code': 'SD',
'rule_ids': [(4, self.hra_rule_id), (4, self.conv_rule_id),
(4, self.prof_tax_rule_id), (4, self.pf_rule_id),
(4, self.mv_rule_id)],
})
# I create a contract for "Richard"
self.env['hr.contract'].create({
'date_end': Date.to_string((datetime.now() + timedelta(days=365))),
'date_start': Date.today(),
'name': 'Contract for Richard',
'wage': 5000.0,
'type_id': self.ref('hr_contract.hr_contract_type_emp'),
'employee_id': self.richard_emp.id,
'struct_id': self.developer_pay_structure.id,
})