Bharat Devnani (Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-908986-bde into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #908986 in OpenERP Addons: "hr - create new employee"
https://bugs.launchpad.net/openobject-addons/+bug/908986
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-908986-bde/+merge/87343
Hello Sir,
I have made some changes in _set_remaining_days method
and also improved tool tip in the same method.
Thanks & Regards,
Devnani Bharat R.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-908986-bde/+merge/87343
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-908986-bde.
=== modified file 'hr_holidays/hr_holidays.py'
--- hr_holidays/hr_holidays.py 2011-12-30 12:28:11 +0000
+++ hr_holidays/hr_holidays.py 2012-01-03 12:43:34 +0000
@@ -359,27 +359,28 @@
_inherit="hr.employee"
def _set_remaining_days(self, cr, uid, empl_id, name, value, arg, context=None):
- employee = self.browse(cr, uid, empl_id, context=context)
- diff = value - employee.remaining_leaves
- type_obj = self.pool.get('hr.holidays.status')
- 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 must 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:
- 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
- wf_service = netsvc.LocalService("workflow")
- 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 value:
+ employee = self.browse(cr, uid, empl_id, context=context)
+ diff = value - employee.remaining_leaves
+ type_obj = self.pool.get('hr.holidays.status')
+ 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 'Remaining Legal Leaves' feature, you must have only one leave type defined with the option 'Allow to Override Limit' unchecked (%s Found).") % (len(status_ids)))
+ status_id = status_ids and status_ids[0] or False
+ 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
+ wf_service = netsvc.LocalService("workflow")
+ 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)
return True
def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp