[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.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user