Now only validated allocation requests are taken into account
when computing the number of virtual remaining leaves (leaves
+ pending leaves). This avoid creating allocation request to
have virtual remaining leaves artificially added.
for holiday in self.pool['hr.holidays'].browse(cr, uid, holiday_ids, context=context):
status_dict = result[holiday.holiday_status_id.id]
if holiday.type == 'add':
for holiday in self.pool['hr.holidays'].browse(cr, uid, holiday_ids, context=context):
status_dict = result[holiday.holiday_status_id.id]
if holiday.type == 'add':
- status_dict['virtual_remaining_leaves'] += holiday.number_of_days
if holiday.state == 'validate':
if holiday.state == 'validate':
+ # note: add only validated allocation even for the virtual
+ # count; otherwise pending then refused allocation allow
+ # the employee to create more leaves than possible
+ status_dict['virtual_remaining_leaves'] += holiday.number_of_days
status_dict['max_leaves'] += holiday.number_of_days
status_dict['remaining_leaves'] += holiday.number_of_days
elif holiday.type == 'remove': # number of days is negative
status_dict['max_leaves'] += holiday.number_of_days
status_dict['remaining_leaves'] += holiday.number_of_days
elif holiday.type == 'remove': # number of days is negative