diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index d8605f297b0..9ff647b0231 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -333,10 +333,17 @@ class hr_employee(osv.osv): holiday_obj = self.pool.get('hr.holidays') # Find for holidays status status_ids = type_obj.search(cr, uid, [('limit', '=', False)], context=context) + if len(status_ids) != 1 : + raise osv.except_osv(('warning !'),_("To use this feature, you should have only one leave type without the option 'Allow to Override Limit' set (%s Found).") % (len(status_ids))) status_id = status_ids and status_ids[0] or False - if not status_id or diff <= 0: + if not status_id: + return False + if diff > 0: + leave_id = holiday_obj.create(cr, uid, {'name': _('Allocation for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context) + elif diff < 0: + leave_id = holiday_obj.create(cr, uid, {'name': _('Leave Request for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'remove', 'holiday_type': 'employee', 'number_of_days_temp': abs(diff)}, context=context) + else: return False - leave_id = holiday_obj.create(cr, uid, {'name': 'Allocation for ' + employee.name,'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context) holiday_obj.holidays_confirm(cr, uid, [leave_id]) holiday_obj.holidays_validate2(cr, uid, [leave_id]) return True diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 825f8b672d2..2c0debb3552 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -5,7 +5,6 @@ Legal Leaves - False black @@ -20,7 +19,7 @@ Compensatory Days - False + True brown diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 56fb7faddfc..b6d495c1cb5 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -451,7 +451,7 @@ - +