summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Peiffer (ACSONE) <adrien.peiffer@acsone.eu>2017-04-12 18:17:27 +0200
committerNicolas Martinelli <nim@odoo.com>2017-04-18 12:52:46 +0200
commitf160bba4d1dca8616de6b0f0246444dfe0d4dbdf (patch)
tree9ea5c3fbf8c59bbdb7d4a42cf15044c194acedb9
parentc043db5e3b52e1b28cf21aa5d851394650f1ff8e (diff)
[IMP] hr_holidays: improve inheritance
Improve inheritance on allocation creation by employee's tag. opw-728620 Closes #16402
-rw-r--r--addons/hr_holidays/models/hr_holidays.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/addons/hr_holidays/models/hr_holidays.py b/addons/hr_holidays/models/hr_holidays.py
index 9b4daa0f5bf..469a60f0231 100644
--- a/addons/hr_holidays/models/hr_holidays.py
+++ b/addons/hr_holidays/models/hr_holidays.py
@@ -440,6 +440,23 @@ class Holidays(models.Model):
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'):
raise UserError(_('Only an HR Officer or Manager can approve leave requests.'))
@@ -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()