This question has been flagged
1 Reply
6668 Views

Hello friends :)

Please, i have tried to add some fields in the menu Human Ressources.

So, i use an on_change function which gave me error that i havent resolve yet.

Here is my code:


 def on_change_contract_id(self, cr, uid, ids,  field_name, context=None):
if field_name == False:
My_error_Msg = 'Please, select your EMPLOYEE'
raise osv.except_osv(_("Error!"), _(My_error_Msg))
else:
print employee_id
obj = self.pool.get('hr.contract')
obj_ids = obj.search(cr, uid, [('employee_id', '=', field_name)])
res = obj.read(cr, uid, obj_ids, ['name'], context)
res = {'value':{.................................;
}
}
return res

The problem is that i need to work with the employee_id but i didnt understand how to be able to use it when i try the inheritance.

Need an answer please

Avatar
Discard
Best Answer

 you can write print self.employee_id instead of print employee_id

Try like this way ,

 def on_change_contract_id(self, cr, uid, ids,  field_name, context=None):
if field_name == False:
My_error_Msg = 'Please, select your EMPLOYEE'
raise osv.except_osv(_("Error!"), _(My_error_Msg))
else:
print self.employee_id
obj = self.pool.get('hr.contract')
obj_ids = obj.search(cr, uid, [('employee_id', '=', field_name)])
res = obj.read(cr, uid, obj_ids, ['name'], context)
res = {'value':{.................................;
}
}
return res


correct me,If i am wrong 

Thank you

Avatar
Discard