[IMP] hr_holidays: improve inheritance

Improve inheritance on allocation creation by employee's tag.

opw-728620
Closes #16402
This commit is contained in:
Adrien Peiffer (ACSONE)
2017-04-18 12:52:46 +02:00
committed by Nicolas Martinelli
parent c043db5e3b
commit f160bba4d1
+18 -12
View File
@@ -439,6 +439,23 @@ class Holidays(models.Model):
else:
holiday.action_validate()
@api.multi
def _prepare_create_by_category(self, employee):
self.ensure_one()
values = {
'name': self.name,
'type': self.type,
'holiday_type': 'employee',
'holiday_status_id': self.holiday_status_id.id,
'date_from': self.date_from,
'date_to': self.date_to,
'notes': self.notes,
'number_of_days_temp': self.number_of_days_temp,
'parent_id': self.id,
'employee_id': employee.id
}
return values
@api.multi
def action_validate(self):
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
@@ -479,18 +496,7 @@ class Holidays(models.Model):
elif holiday.holiday_type == 'category':
leaves = self.env['hr.holidays']
for employee in holiday.category_id.employee_ids:
values = {
'name': holiday.name,
'type': holiday.type,
'holiday_type': 'employee',
'holiday_status_id': holiday.holiday_status_id.id,
'date_from': holiday.date_from,
'date_to': holiday.date_to,
'notes': holiday.notes,
'number_of_days_temp': holiday.number_of_days_temp,
'parent_id': holiday.id,
'employee_id': employee.id
}
values = holiday._prepare_create_by_category(employee)
leaves += self.with_context(mail_notify_force_send=False).create(values)
# TODO is it necessary to interleave the calls?
leaves.action_approve()