Odoo Help


Openerp Custom leave Logic

on 1/23/15, 7:30 AM 990 views

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.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/23/15, 7:30 AM
Seen: 990 times
Last updated: 3/16/15, 8:10 AM