[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)
This commit is contained in:
RomainLibert
2018-12-18 15:03:27 +00:00
committed by Yannick Tivisse
parent d5fd84b89a
commit 939f8e0534
6 changed files with 64 additions and 9 deletions
+6
View File
@@ -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:
+2 -1
View File
@@ -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
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Employee View -->
<record id="payroll_hr_employee_view_form" model="ir.ui.view">
<field name="name">payroll.hr.employee.view.form</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<button name="toggle_active" position="before">
<xpath expr="//button[@name='toggle_active']" position="before">
<button name="%(act_hr_employee_payslip_list)d"
class="oe_stat_button"
icon="fa-money"
@@ -15,7 +14,10 @@
groups="hr_payroll.group_hr_payroll_user">
<field name="payslip_count" widget="statinfo" string="Payslips"/>
</button>
</button>
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="registration_number"/>
</xpath>
</field>
</record>
</odoo>
</odoo>
@@ -5,8 +5,24 @@
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">
<h2>Pay Slip</h2>
<p t-field="o.name"/>
<h2 t-field="o.name"/>
<table class="table table-sm table-bordered">
<tr>
<td><strong>Company Information</strong></td>
<td>
<div><span t-field="o.company_id.name"/></div>
<div><span t-field="o.company_id.street"/></div>
<div><span t-field="o.company_id.street2" t-if="o.company_id.street2"/></div>
<div>
<span t-field="o.company_id.city"/>
<span t-field="o.company_id.state_id"/>
<span t-field="o.company_id.zip"/>
</div>
<div><span t-field="o.company_id.country_id"/></div>
</td>
</tr>
</table>
<table class="table table-sm table-bordered">
<tr>
@@ -40,6 +56,22 @@
<td><strong>Date To</strong></td>
<td><span t-field="o.date_to"/></td>
</tr>
<tr>
<td><strong>Computed On</strong></td>
<td><span t-field="o.compute_date"/></td>
<td><strong>Registration Number</strong></td>
<td><span t-field="o.employee_id.registration_number"/></td>
</tr>
</table>
<table class="table table-sm">
<tr>
<td><strong>Basic Salary</strong></td>
<td>
<span t-esc="o.line_ids.filtered(lambda line: line.code == 'BASIC').total"
t-options='{"widget": "monetary", "display_currency": o.company_id.currency_id}'/>
</td>
</tr>
</table>
<table class="table table-sm">
@@ -47,21 +79,33 @@
<tr>
<th>Code</th>
<th>Name</th>
<th>Number of Hours</th>
<th>Number of Days</th>
<th>Quantity/rate</th>
<th>Amount</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.line_ids.filtered(lambda line: line.appears_on_payslip)" t-as="line">
<tr t-foreach="o.worked_days_line_ids" t-as="worked_days">
<td><span t-field="worked_days.code"/></td>
<td><span t-field="worked_days.name"/></td>
<td><span t-field="worked_days.number_of_hours"/></td>
<td><span t-field="worked_days.number_of_days"/></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr t-foreach="o.line_ids.filtered(lambda line: line.appears_on_payslip)" t-as="line">
<td><span t-field="line.code"/></td>
<td><span t-field="line.name"/></td>
<td></td>
<td></td>
<td><span t-field="line.quantity"/></td>
<td><span t-esc="line.amount"
t-options='{"widget": "monetary", "display_currency": o.company_id.currency_id}'/></td>
<td><span t-esc="line.total"
t-options='{"widget": "monetary", "display_currency": o.company_id.currency_id}'/></td>
</tr>
</tbody>
</table>
@@ -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,
}
@@ -25,4 +25,5 @@ Belgian Payroll Rules.
'data/l10n_be_hr_payroll_data.xml',
'views/res_config_settings_views.xml',
],
'auto_install': True,
}