_description = "Process"
_columns = {
'name': fields.char('Name', size=30,required=True, translate=True),
- 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the process without removing it."),
+ 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the process without removing it."),
'model_id': fields.many2one('ir.model', 'Object', ondelete='set null'),
'note': fields.text('Notes', translate=True),
'node_ids': fields.one2many('process.node', 'process_id', 'Nodes')
pool = pooler.get_pool(cr.dbname)
- process = pool.get('process.process').browse(cr, uid, [id], context=context)[0]
+ process = pool.get('process.process').browse(cr, uid, id, context=context)
name = process.name
- resource = None
+ resource = False
state = 'N/A'
expr_context = {}
states = {}
- perm = None
+ 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)[0]
- current_user = pool.get('res.users').browse(cr, uid, [uid], context=context)[0]
+ 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:
if node.menu_id:
data['menu'] = {'name': node.menu_id.complete_name, 'id': node.menu_id.id}
- if node.model_id and node.model_id.model == res_model:
- try:
- data['active'] = eval(node.model_states, expr_context)
- except Exception:
- pass
-
- if not data['active']:
- try:
- gray = True
- for cond in node.condition_ids:
- if cond.model_id and cond.model_id.model == res_model:
- gray = gray and eval(cond.model_states, expr_context)
- data['gray'] = not gray
- except:
- pass
+ try:
+ gray = True
+ for cond in node.condition_ids:
+ if cond.model_id and cond.model_id.model == res_model:
+ gray = gray and eval(cond.model_states, expr_context)
+ data['gray'] = not gray
+ except:
+ pass
+
+ if not data['gray']:
+ if node.model_id and node.model_id.model == res_model:
+ try:
+ data['active'] = eval(node.model_states, expr_context)
+ except Exception:
+ pass
nodes[node.id] = data
if node.flow_start:
nodes[nid]['res'] = resource = {'id': ref_id, 'model': ref_model}
- refobj = pool.get(ref_model).browse(cr, uid, [ref_id], context=context)[0]
+ refobj = pool.get(ref_model).browse(cr, uid, ref_id, context=context)
fields = pool.get(ref_model).fields_get(cr, uid, context=context)
# check for directory_id from inherited from document module
for k, v in nodes.items():
y = v['y']
v['y'] = min(y - miny + 10, y)
-
+
+ nodes = dict([str(n_key), n_val] for n_key, n_val in nodes.iteritems())
+ transitions = dict([str(t_key), t_val] for t_key, t_val in transitions.iteritems())
return dict(name=name, resource=resource, state=state, perm=perm, notes=notes, nodes=nodes, transitions=transitions)
def copy(self, cr, uid, id, default=None, context=None):
default = {}
pool = pooler.get_pool(cr.dbname)
- process = pool.get('process.process').browse(cr, uid, [id], context=context)[0]
+ process = pool.get('process.process').browse(cr, uid, id, context=context)
nodes = {}
transitions = {}
if not default:
default = {}
- state = self.pool.get('process.transition.action').browse(cr, uid, [id], context=context)[0].state
+ state = self.pool.get('process.transition.action').browse(cr, uid, id, context=context).state
if state:
default['state'] = state