-
- process = pool.get('process.process').browse(cr, uid, [id])[0]
- current_object = pool.get(res_model).browse(cr, uid, [res_id], context)[0]
- current_user = pool.get('res.users').browse(cr, uid, [uid], context)[0]
-
- expr_context = Env(current_object, current_user)
-
- notes = process.note
+
+ process = pool.get('process.process').browse(cr, uid, id, context=context)
+
+ name = process.name
+ resource = False
+ state = 'N/A'
+
+ expr_context = {}
+ states = {}
+ perm = False
+
+ if res_model:
+ states = dict(pool.get(res_model).fields_get(cr, uid, context=context).get('state', {}).get('selection', {}))
+
+ if res_id:
+ current_object = pool.get(res_model).browse(cr, uid, res_id, context=context)
+ current_user = pool.get('res.users').browse(cr, uid, uid, context=context)
+ expr_context = Env(current_object, current_user)
+ resource = current_object.name
+ if 'state' in current_object:
+ state = states.get(current_object.state, 'N/A')
+ perm = pool.get(res_model).perm_read(cr, uid, [res_id], context=context)[0]
+
+ notes = process.note or "N/A"