Odoo Help

Welcome!

This community 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.

0

Openerp Custom leave Logic

By
Sivakiran
on 1/23/15, 7:30 AM 591 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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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