Skip to Content
Menu
This question has been flagged

in an organization leave allocation for a group of employees happens in float numbers, Example Paid:0.5,Casual 0.5. So in general case an employee cannot apply for leave under paid or casual. But  Here, even if the employee has insufficient leave days, the next category leave has to be selected, and should be deducted from it. Example if i select Paid leave for 1 day, 0.5 will be taken from paid and 0.5 from casual should be deducted and will be added to paid leave.

I was successfull in adding the leaves, with this logic

hol_id =  holiday_obj.create(cr, uid, {'name': _('AUTO ALLOCATED'), 'employee_id': record.employee_id.id, 'holiday_status_id': record.holiday_status_id.id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': int(abs(leave_days['virtual_remaining_leaves'])),'state':'validate'}, context=context)
                            self.write(cr, uid,[hol_id],{'state':'validate'})

I sent type=add and number_of_days_temp, it successfully added. But when iam deducting leaves by this logic

 

leave_id =  holiday_obj.create(cr, uid, {'name': _('removel test '), 'employee_id': record.employee_id.id, 'holiday_status_id': r['id'], 'type': 'remove', 'holiday_type': 'employee', 'number_of_days_temp': int(abs(leave_days['virtual_remaining_leaves'])),'state':'validate'}, context=context)
                            self.write(cr, uid,[leave_id],{'state':'validate'})

When iam sending type=remove, it was raising an exception, stating String Expected ,Bool returned..

 

MY explanation may be lengthy , because requirement if typical.

Avatar
Discard
Related Posts Replies Views Activity
3
Sep 18
5407
0
Feb 16
3522
0
Aug 15
5358
1
Mar 15
356
3
Mar 15
360