fix holiday
This commit is contained in:
parent
9eefc082cd
commit
e05a9dd62c
|
|
@ -487,20 +487,22 @@ class HRHolidays(models.Model):
|
||||||
last_date = datetime.strftime(today, "{0}-12-31".format(years))
|
last_date = datetime.strftime(today, "{0}-12-31".format(years))
|
||||||
last_date = datetime.strptime(str(last_date), "%Y-%m-%d").date()
|
last_date = datetime.strptime(str(last_date), "%Y-%m-%d").date()
|
||||||
start_days = last_date - timedelta(days=int(holiday.remained_before))
|
start_days = last_date - timedelta(days=int(holiday.remained_before))
|
||||||
if today < last_date:
|
|
||||||
balance = self.env['hr.holidays'].search([('employee_id', '=', emp.id),
|
if start_days <= today < last_date:
|
||||||
|
if today.weekday() != 6: # Send on Sunday only, not every day
|
||||||
|
return
|
||||||
|
balance = self.env['hr.holidays'].search([('employee_id', '=', emp.id),
|
||||||
('holiday_status_id', '=', holiday.id),
|
('holiday_status_id', '=', holiday.id),
|
||||||
('type', '=', 'add'),
|
('type', '=', 'add'),
|
||||||
('check_allocation_view', '=', 'balance')
|
('check_allocation_view', '=', 'balance')
|
||||||
], limit=1, order="id desc")
|
], limit=1, order="id desc")
|
||||||
holi_balance = balance.remaining_leaves or 0.0
|
holi_balance = balance.remaining_leaves or 0.0
|
||||||
if today >= start_days < last_date:
|
if holi_balance > holiday.number_of_save_days:
|
||||||
if holi_balance > holiday.number_of_save_days:
|
if emp.user_id:
|
||||||
if emp.user_id:
|
template = self.env.ref('hr_holidays_public.email_template_holiday_balance', False)
|
||||||
template = self.env.ref('hr_holidays_public.email_template_holiday_balance', False)
|
template.write({'email_to': emp.user_id.partner_id.email, 'lang': emp.user_id.lang,
|
||||||
template.write({'email_to': emp.user_id.partner_id.email, 'lang': emp.user_id.lang,
|
'email_cc': '%s' % (self.env.user.company_id.hr_email)})
|
||||||
'email_cc': '%s' % (self.env.user.company_id.hr_email)})
|
template.send_mail(balance.id)
|
||||||
template.send_mail(balance.id)
|
|
||||||
if holiday.payslip_type == 'unpaid':
|
if holiday.payslip_type == 'unpaid':
|
||||||
tomorrow = (fields.Datetime.from_string(fields.Datetime.now()) + timedelta(days=1)).strftime(
|
tomorrow = (fields.Datetime.from_string(fields.Datetime.now()) + timedelta(days=1)).strftime(
|
||||||
'%Y-%m-%d 00:00:00')
|
'%Y-%m-%d 00:00:00')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue