I want define a function that say:
forexample in project form (that has a field by name : "department_id") :
if field 'department_id' s manager s user_id IS == with login user
so
a variable for example 'x' set to 'True'
else
'x' set to 'False'
-------------------------------------
my openerp version : 6.1 and use old api
I think that I have use a function field ( 'x' : fields.function(_compute_el , type='boolean'), )
and write a function.
but I don't know how?
--------------------------------------------my code is:
def _compute_el(self, cr, uid, ids , x , department_id, context=None):
x = False
if department_id.manager_id.user_id == user.id:
x = True
else:
x = False
return {'value': {'x' : x}}
_columns = {
'x' : fields.function(_compute_el),
'department_id': fields.many2one('hr.department', 'Department'),
...... }
-------------------------------------------------
I write this: ( if department_id.manager_id.user_id == user.id: )
but does not work. error:
if department_id.manager_id.user_id == user.id:
AttributeError: 'NoneType' object has no attribute 'manager_id'
-----------------------Thanks