I've been trying to override the default payslip confirm action but it's not showing any changes but Overriding the compute_sheet() function works fine.
I'm I making a mistake that i can't see??
class JengaPayslip(models.Model):
# inherit base payslip model
_inherit = "hr.payslip"
_description = "Payslip"
@api.multi
def action_payslip_done(self):
month = self.date_from.strftime('%B')
year = self.date_from.strftime('%Y')
if self.env['hr.payslip.tracker'].search([('employee_id', '=', self.employee_id.id), ('contract_id', '=', self.contract_id.id), ('month', '=', month), ('year', '=', year)]):
raise UserError(
"The payslip you're trying to confirm has already been confirmed.")
# Register the payslip in the tracker
self.env['hr.payslip.tracker'].create({
'slip_id': self.id,
'employee_id': self.employee_id.id,
'contract_id': self.contract_id.id,
'month': month,
'year': year,
})
self.env.cr.commit()
# Set repaid loan to paid
employee_loan = self.env['jenga_hr.employee_loan'].search(
[('employee_id', '=', self.employee_id.id), ('state', '=', 'approve')])
repayment = self.env['jenga_hr.employee_loan.repayment'].search([('loan_id', 'in', employee_loan.ids), (
'state', '=', 'pending'), ('repayment_month', '=', self.date_from.strftime('%B/%Y'))])
if repayment:
repayment.write({'state': 'paid'})
self.compute_sheet()
return self.write({'state': 'done'})