diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py
index d3021cf4c39..a2c9324914b 100644
--- a/addons/hr_holidays/hr_holidays.py
+++ b/addons/hr_holidays/hr_holidays.py
@@ -124,8 +124,6 @@ class hr_holidays(osv.osv):
'date_to': fields.datetime('End Date', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
'holiday_status_id': fields.many2one("hr.holidays.status", "Leave Type", required=True,readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
'employee_id': fields.many2one('hr.employee', "Employee", select=True, invisible=False, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, help='Leave Manager can let this field empty if this leave request/allocation is for every employee'),
- #'manager_id': fields.many2one('hr.employee', 'Leave Manager', invisible=False, readonly=True, help='This area is automatically filled by the user who validate the leave'),
- #'notes': fields.text('Notes',readonly=True, states={'draft':[('readonly',False)]}),
'manager_id': fields.many2one('hr.employee', 'First Approval', invisible=False, readonly=True, help='This area is automatically filled by the user who validate the leave'),
'notes': fields.text('Reasons',readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
'number_of_days_temp': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
@@ -135,8 +133,8 @@ class hr_holidays(osv.osv):
'parent_id': fields.many2one('hr.holidays', 'Parent'),
'linked_request_ids': fields.one2many('hr.holidays', 'parent_id', 'Linked Requests',),
'department_id':fields.related('employee_id', 'department_id', string='Department', type='many2one', relation='hr.department', readonly=True, store=True),
- 'category_id': fields.many2one('hr.employee.category', "Category", help='Category of Employee'),
- 'holiday_type': fields.selection([('employee','By Employee'),('category','By Employee Category')], 'Allocation Type', help='By Employee: Allocation/Request for individual Employee, By Employee Category: Allocation/Request for group of employees in category', required=True),
+ 'category_id': fields.many2one('hr.employee.category', "Category", help='Category of Employee', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
+ 'holiday_type': fields.selection([('employee','By Employee'),('category','By Employee Category')], 'Allocation Mode', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, help='By Employee: Allocation/Request for individual Employee, By Employee Category: Allocation/Request for group of employees in category', required=True),
'manager_id2': fields.many2one('hr.employee', 'Second Approval', readonly=True, help='This area is automaticly filled by the user who validate the leave with second level (If Leave type need second validation)'),
'double_validation': fields.related('holiday_status_id', 'double_validation', type='boolean', relation='hr.holidays.status', string='Apply Double Validation'),
}
@@ -244,25 +242,26 @@ class hr_holidays(osv.osv):
self.unlink(cr, uid, to_unlink, context=context)
return True
- def holidays_validate(self, cr, uid, ids, context=None):
+ def holidays_first_validate(self, cr, uid, ids, context=None):
self.check_holidays(cr, uid, ids, context=context)
obj_emp = self.pool.get('hr.employee')
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
manager = ids2 and ids2[0] or False
- self.holidays_validate_notificate(cr, uid, ids, context=context)
+ self.holidays_first_validate_notificate(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state':'validate1', 'manager_id': manager})
- def holidays_validate2(self, cr, uid, ids, context=None):
+ def holidays_validate(self, cr, uid, ids, context=None):
self.check_holidays(cr, uid, ids, context=context)
obj_emp = self.pool.get('hr.employee')
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
manager = ids2 and ids2[0] or False
self.write(cr, uid, ids, {'state':'validate'})
data_holiday = self.browse(cr, uid, ids)
- holiday_ids = []
for record in data_holiday:
- if record.holiday_status_id.double_validation:
- holiday_ids.append(record.id)
+ if record.double_validation:
+ self.write(cr, uid, [record.id], {'manager_id2': manager})
+ else:
+ self.write(cr, uid, [record.id], {'manager_id': manager})
if record.holiday_type == 'employee' and record.type == 'remove':
meeting_obj = self.pool.get('crm.meeting')
meeting_vals = {
@@ -301,9 +300,7 @@ class hr_holidays(osv.osv):
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr)
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr)
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr)
- if holiday_ids:
- self.holidays_valid2_notificate(cr, uid, holiday_ids, context=context)
- self.write(cr, uid, holiday_ids, {'manager_id2': manager})
+ self.holidays_validate_notificate(cr, uid, ids, context=context)
return True
def holidays_confirm(self, cr, uid, ids, context=None):
@@ -311,15 +308,16 @@ class hr_holidays(osv.osv):
self.holidays_confirm_notificate(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state':'confirm'})
- def holidays_refuse(self, cr, uid, ids, approval, context=None):
+ def holidays_refuse(self, cr, uid, ids, context=None):
obj_emp = self.pool.get('hr.employee')
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
manager = ids2 and ids2[0] or False
- if approval == 'first_approval':
- self.write(cr, uid, ids, {'state': 'refuse', 'manager_id': manager})
- else:
- self.write(cr, uid, ids, {'state': 'refuse', 'manager_id2': manager})
- self.holidays_refuse_notificate(cr, uid, ids, approval, context=context)
+ for holiday in self.browse(cr, uid, ids, context=context):
+ if holiday.state == 'validate1':
+ self.write(cr, uid, [holiday.id], {'state': 'refuse', 'manager_id': manager})
+ else:
+ self.write(cr, uid, [holiday.id], {'state': 'refuse', 'manager_id2': manager})
+ self.holidays_refuse_notificate(cr, uid, ids, context=context)
self.holidays_cancel(cr, uid, ids, context=context)
return True
@@ -333,7 +331,7 @@ class hr_holidays(osv.osv):
# If a category that created several holidays, cancel all related
wf_service = netsvc.LocalService("workflow")
for request in record.linked_request_ids or []:
- wf_service.trg_validate(uid, 'hr.holidays', request.id, 'cancel', cr)
+ wf_service.trg_validate(uid, 'hr.holidays', request.id, 'refuse', cr)
self._remove_resource_leave(cr, uid, ids, context=context)
return True
@@ -355,7 +353,7 @@ class hr_holidays(osv.osv):
def get_needaction_user_ids(self, cr, uid, ids, context=None):
result = super(hr_holidays, self).get_needaction_user_ids(cr, uid, ids, context=context)
for obj in self.browse(cr, uid, ids, context=context):
- if obj.state == 'confirm' and obj.employee_id.parent_id:
+ if obj.state == 'confirm' and obj.holiday_type == 'employee' and obj.employee_id.parent_id:
result[obj.id] = [obj.employee_id.parent_id.user_id.id]
elif obj.state == 'validate1':
# get group_hr_manager: everyone will be warned of second validation
@@ -389,24 +387,25 @@ class hr_holidays(osv.osv):
_("The %s request has been submitted and is waiting for validation by the manager.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification')
+ def holidays_first_validate_notificate(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids):
+ self.message_append_note(cr, uid, [obj.id], _('System notification'),
+ _("The %s request has been approved. A second validation is necessary and is now pending.")
+ % ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
+
def holidays_validate_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
- if obj.holiday_status_id.double_validation:
+ if obj.double_validation:
self.message_append_note(cr, uid, [obj.id], _('System notification'),
- _("The %s request has been approved. A second validation is necessary and is now pending.")
+ _("The %s request has been double validated. The validation process is now over.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
else:
self.message_append_note(cr, uid, [obj.id], _('System notification'),
_("The %s request has been approved. The validation process is now over.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
- def holidays_valid2_notificate(self, cr, uid, ids, context=None):
- for obj in self.browse(cr, uid, ids):
- self.message_append_note(cr, uid, [obj.id], _('System notification'),
- _("The %s request has been double validated. The validation process is now over.")
- % ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
- def holidays_refuse_notificate(self, cr, uid, ids, approval, context=None):
+ def holidays_refuse_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
_("The %s request has been refused. The validation process is now over.")
diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml
index 1f269f88f86..66a3e8cb62f 100644
--- a/addons/hr_holidays/hr_holidays_view.xml
+++ b/addons/hr_holidays/hr_holidays_view.xml
@@ -96,7 +96,7 @@