Skip to content
Snippets Groups Projects
Commit f29d9dfe authored by Yannick Tivisse's avatar Yannick Tivisse
Browse files

[IMP] hr_payroll: Put single payslips in a batch.

When creating a payslip, if no batch is defined for it, put it
automatically in a new batch.
parent 9bab1ed2
Branches
Tags
No related merge requests found
......@@ -112,6 +112,19 @@ class HrPayslip(models.Model):
'context': {}
}
@api.model
def create(self, vals):
res = super(HrPayslip, self).create(vals)
if not res.payslip_run_id:
self.env['hr.payslip.run'].create({
'name': res.name,
'date_start': res.date_from,
'date_end': res.date_to,
'slip_ids': [(4, res.id)],
'state': 'close',
})
return res
@api.multi
def unlink(self):
if any(self.filtered(lambda payslip: payslip.state not in ('draft', 'cancel'))):
......
......@@ -74,6 +74,7 @@ class TestHrPayrollAccount(common.TransactionCase):
self.hr_payslip = self.env['hr.payslip'].create({
'employee_id': self.hr_employee_john.id,
'journal_id': self.ref('hr_payroll_account.expenses_journal'),
'name': 'Test Payslip',
})
def test_00_hr_payslip(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment