From 939f8e05347e2a07bf2639b652c7deaa6c00c837 Mon Sep 17 00:00:00 2001 From: RomainLibert Date: Mon, 26 Nov 2018 15:58:44 +0000 Subject: [PATCH] [IMP] hr_payroll: add legal information to payslip report This commit adds two fields: - compute_date on payslip (set once computed) - registration_number on employee (used to identify the employee) These fields are displayed in the payslip_report It also adds the worked_days to the same report These fields are a legal obligation in some countries (like Belgium) --- addons/hr_payroll/models/hr_employee.py | 6 +++ addons/hr_payroll/models/hr_payslip.py | 3 +- addons/hr_payroll/views/hr_employee_views.xml | 10 ++-- .../views/report_payslip_templates.xml | 52 +++++++++++++++++-- addons/hr_payroll_account/__manifest__.py | 1 + addons/l10n_be_hr_payroll/__manifest__.py | 1 + 6 files changed, 64 insertions(+), 9 deletions(-) diff --git a/addons/hr_payroll/models/hr_employee.py b/addons/hr_payroll/models/hr_employee.py index 4570063ad91..2521c227a6c 100644 --- a/addons/hr_payroll/models/hr_employee.py +++ b/addons/hr_payroll/models/hr_employee.py @@ -14,6 +14,12 @@ class HrEmployee(models.Model): slip_ids = fields.One2many('hr.payslip', 'employee_id', string='Payslips', readonly=True) payslip_count = fields.Integer(compute='_compute_payslip_count', string='Payslip Count', groups="hr_payroll.group_hr_payroll_user") + registration_number = fields.Char('Registration Number of the Employee', copy=False) + + _sql_constraints = [ + ('unique_registration_number', 'UNIQUE(registration_number, company_id)', 'No duplication of registration numbers is allowed') + ] + @api.multi def _compute_payslip_count(self): for employee in self: diff --git a/addons/hr_payroll/models/hr_payslip.py b/addons/hr_payroll/models/hr_payslip.py index d902987c3e2..626d84c9414 100644 --- a/addons/hr_payroll/models/hr_payslip.py +++ b/addons/hr_payroll/models/hr_payslip.py @@ -66,6 +66,7 @@ class HrPayslip(models.Model): payslip_run_id = fields.Many2one('hr.payslip.run', string='Payslip Batches', readonly=True, copy=False, states={'draft': [('readonly', False)]}) payslip_count = fields.Integer(compute='_compute_payslip_count', string="Payslip Computation Details") + compute_date = fields.Date('Computed On') @api.multi def _compute_payslip_count(self): @@ -143,7 +144,7 @@ class HrPayslip(models.Model): contracts = payslip.contract_id or \ payslip.employee_id._get_contracts(payslip.date_from, payslip.date_to) lines = [(0, 0, line) for line in payslip._get_payslip_lines(contracts)] - payslip.write({'line_ids': lines, 'number': number, 'state': 'verify'}) + payslip.write({'line_ids': lines, 'number': number, 'state': 'verify', 'compute_date': fields.Date.today()}) return True @api.model diff --git a/addons/hr_payroll/views/hr_employee_views.xml b/addons/hr_payroll/views/hr_employee_views.xml index 20b765e6910..85e289719d9 100644 --- a/addons/hr_payroll/views/hr_employee_views.xml +++ b/addons/hr_payroll/views/hr_employee_views.xml @@ -1,13 +1,12 @@ - payroll.hr.employee.view.form hr.employee - - + + + + - \ No newline at end of file + diff --git a/addons/hr_payroll/views/report_payslip_templates.xml b/addons/hr_payroll/views/report_payslip_templates.xml index 876ce15de26..b968a9eb58e 100644 --- a/addons/hr_payroll/views/report_payslip_templates.xml +++ b/addons/hr_payroll/views/report_payslip_templates.xml @@ -5,8 +5,24 @@
-

Pay Slip

-

+

+ + + + + + +
Company Information +
+
+
+
+ + + +
+
+
@@ -40,6 +56,22 @@ + + + + + + +
Date To
Computed OnRegistration Number
+ + + + + +
Basic Salary + +
@@ -47,21 +79,33 @@ + + - + + + + + + + + + + + + -
Code NameNumber of HoursNumber of Days Quantity/rate Amount Total
diff --git a/addons/hr_payroll_account/__manifest__.py b/addons/hr_payroll_account/__manifest__.py index 0af1cbe0c90..fe56ebf6ffa 100644 --- a/addons/hr_payroll_account/__manifest__.py +++ b/addons/hr_payroll_account/__manifest__.py @@ -15,4 +15,5 @@ Generic Payroll system Integrated with Accounting. 'data': ['views/hr_payroll_account_views.xml'], 'demo': ['data/hr_payroll_account_demo.xml'], 'test': ['../account/test/account_minimal_test.xml'], + 'auto_install': True, } diff --git a/addons/l10n_be_hr_payroll/__manifest__.py b/addons/l10n_be_hr_payroll/__manifest__.py index 1c6d178f8a4..5a1f5c00865 100644 --- a/addons/l10n_be_hr_payroll/__manifest__.py +++ b/addons/l10n_be_hr_payroll/__manifest__.py @@ -25,4 +25,5 @@ Belgian Payroll Rules. 'data/l10n_be_hr_payroll_data.xml', 'views/res_config_settings_views.xml', ], + 'auto_install': True, }