Hello bros:
How can we get last payslip date for a particular employee.
Basically i want to calculate days between last payslip date and resign date. For example last payslip for an employee "Ali" was generated in 02/02/2020. Then how can we get this date in our method.
Another Solution is:
@api.multi
def _get_working_days(self):
fmt = '%Y-%m-%d'
payslip = []
payslip = self.env['hr.payslip'].search([('employee_id', '=', self.employee_id.id)], order='date_from desc',
limit=1)
test = payslip.date_from
d1 = datetime.strptime(test, fmt)
d2 = datetime.strptime(self.joining_date, fmt)
self.working_days = (d1 - d2).days