summaryrefslogtreecommitdiff
path: root/bin/workflow/wkf_expr.py
diff options
context:
space:
mode:
authorChristophe Simonis <christophe@tinyerp.com>2008-07-22 16:24:36 +0200
committerChristophe Simonis <christophe@tinyerp.com>2008-07-22 16:24:36 +0200
commit2dd9723b8b3d38df8c8962300ab67afffa5cdaaa (patch)
tree13dbea91b265af5ad775af16efcdef4ae6ef962c /bin/workflow/wkf_expr.py
parentc5c7c2ef07b346b72eb5a48d6e8cc7a433fba2e8 (diff)
convert tabs to 4 spaces
bzr revid: christophe@tinyerp.com-20080722142436-143iu4ryy47w3av0
Diffstat (limited to 'bin/workflow/wkf_expr.py')
-rw-r--r--bin/workflow/wkf_expr.py116
1 files changed, 58 insertions, 58 deletions
diff --git a/bin/workflow/wkf_expr.py b/bin/workflow/wkf_expr.py
index f1476cc8188..dca3e666efe 100644
--- a/bin/workflow/wkf_expr.py
+++ b/bin/workflow/wkf_expr.py
@@ -34,77 +34,77 @@ import pooler
class EnvCall(object):
- def __init__(self,wf_service,d_arg):
- self.wf_service=wf_service
- self.d_arg=d_arg
+ def __init__(self,wf_service,d_arg):
+ self.wf_service=wf_service
+ self.d_arg=d_arg
- def __call__(self,*args):
- arg=self.d_arg+args
- return self.wf_service.execute_cr(*arg)
+ def __call__(self,*args):
+ arg=self.d_arg+args
+ return self.wf_service.execute_cr(*arg)
class Env(dict):
- def __init__(self, wf_service, cr, uid, model, ids):
- self.wf_service = wf_service
- self.cr = cr
- self.uid = uid
- self.model = model
- self.ids = ids
- self.obj = pooler.get_pool(cr.dbname).get(model)
- self.columns = self.obj._columns.keys() + self.obj._inherit_fields.keys()
+ def __init__(self, wf_service, cr, uid, model, ids):
+ self.wf_service = wf_service
+ self.cr = cr
+ self.uid = uid
+ self.model = model
+ self.ids = ids
+ self.obj = pooler.get_pool(cr.dbname).get(model)
+ self.columns = self.obj._columns.keys() + self.obj._inherit_fields.keys()
- def __getitem__(self, key):
- if (key in self.columns) or (key in dir(self.obj)):
- res = self.obj.browse(self.cr, self.uid, self.ids[0])
- return res[key]
- #res=self.wf_service.execute_cr(self.cr, self.uid, self.model, 'read',\
- # self.ids, [key])[0][key]
- #super(Env, self).__setitem__(key, res)
- #return res
- #elif key in dir(self.obj):
- # return EnvCall(self.wf_service, (self.cr, self.uid, self.model, key,\
- # self.ids))
- else:
- return super(Env, self).__getitem__(key)
+ def __getitem__(self, key):
+ if (key in self.columns) or (key in dir(self.obj)):
+ res = self.obj.browse(self.cr, self.uid, self.ids[0])
+ return res[key]
+ #res=self.wf_service.execute_cr(self.cr, self.uid, self.model, 'read',\
+ # self.ids, [key])[0][key]
+ #super(Env, self).__setitem__(key, res)
+ #return res
+ #elif key in dir(self.obj):
+ # return EnvCall(self.wf_service, (self.cr, self.uid, self.model, key,\
+ # self.ids))
+ else:
+ return super(Env, self).__getitem__(key)
def _eval_expr(cr, ident, workitem, action):
- ret=False
- assert action, 'You used a NULL action in a workflow, use dummy node instead.'
- for line in action.split('\n'):
- uid=ident[0]
- model=ident[1]
- ids=[ident[2]]
- if line =='True':
- ret=True
- elif line =='False':
- ret=False
- else:
- wf_service = netsvc.LocalService("object_proxy")
- env = Env(wf_service, cr, uid, model, ids)
- ret = eval(line, env)
- return ret
+ ret=False
+ assert action, 'You used a NULL action in a workflow, use dummy node instead.'
+ for line in action.split('\n'):
+ uid=ident[0]
+ model=ident[1]
+ ids=[ident[2]]
+ if line =='True':
+ ret=True
+ elif line =='False':
+ ret=False
+ else:
+ wf_service = netsvc.LocalService("object_proxy")
+ env = Env(wf_service, cr, uid, model, ids)
+ ret = eval(line, env)
+ return ret
def execute_action(cr, ident, workitem, activity):
- wf_service = netsvc.LocalService("object_proxy")
- obj = pooler.get_pool(cr.dbname).get('ir.actions.server')
- ctx = {'active_id':ident[2], 'active_ids':[ident[2]]}
- result = obj.run(cr, ident[0], [activity['action_id']], ctx)
- return result
+ wf_service = netsvc.LocalService("object_proxy")
+ obj = pooler.get_pool(cr.dbname).get('ir.actions.server')
+ ctx = {'active_id':ident[2], 'active_ids':[ident[2]]}
+ result = obj.run(cr, ident[0], [activity['action_id']], ctx)
+ return result
def execute(cr, ident, workitem, activity):
- return _eval_expr(cr, ident, workitem, activity['action'])
+ return _eval_expr(cr, ident, workitem, activity['action'])
def check(cr, workitem, ident, transition, signal):
- ok = True
- if transition['signal']:
- ok = (signal==transition['signal'])
+ ok = True
+ if transition['signal']:
+ ok = (signal==transition['signal'])
- if transition['role_id']:
- uid = ident[0]
- serv = netsvc.LocalService('object_proxy')
- user_roles = serv.execute_cr(cr, uid, 'res.users', 'read', [uid], ['roles_id'])[0]['roles_id']
- ok = ok and serv.execute_cr(cr, uid, 'res.roles', 'check', user_roles, transition['role_id'])
- ok = ok and _eval_expr(cr, ident, workitem, transition['condition'])
- return ok
+ if transition['role_id']:
+ uid = ident[0]
+ serv = netsvc.LocalService('object_proxy')
+ user_roles = serv.execute_cr(cr, uid, 'res.users', 'read', [uid], ['roles_id'])[0]['roles_id']
+ ok = ok and serv.execute_cr(cr, uid, 'res.roles', 'check', user_roles, transition['role_id'])
+ ok = ok and _eval_expr(cr, ident, workitem, transition['condition'])
+ return ok