← Back to team overview

openerp-india team mailing list archive

[Bug 1065998] [NEW] Workflow Activity "python action" can't use cr, uid, model, ids

 

Public bug reported:

Python actions defined on Workflow Activities don't have available any variables such as cr, uid, ids, etc.
This can be confirmed by adding to an activite some python code such as:
    print cr, uid

Digging into the trunk code,  /openerp/workflow/wkf_expr.py (revision
4485), in _eval_expr() it looks like the variable (cr, uid, model, ids)
are going to be added to the eval running context.

But actually that's not the case:

(Pdb) l
 53                 ret=True
 54             elif line =='False':
 55                 ret=False
 56             else:
 57                 env = Env(cr, uid, model, ids)
 58  ->             ret = eval(line, env, nocopy=True)
 59         return ret
 60
 61     def execute_action(cr, ident, workitem, activity):
 62         obj = pooler.get_pool(cr.dbname).get('ir.actions.server')
 63         ctx = {'active_model':ident[1], 'active_id':ident[2], 'active_ids':[ident[2]]}
(Pdb) p cr, uid, model, ids
(<openerp.sql_db.Cursor object at 0x9ace8cc>, 1, 'mgmtsystem.nonconformity', [13])
(Pdb) pp env
{'__builtins__': {'False': False,
                  'None': None,
                  'True': True,
                  '__import__': <function _import at 0x89a8374>,
                  'abs': <built-in function abs>,
                  'bool': <type 'bool'>,
                  'dict': <type 'dict'>,
                  'filter': <built-in function filter>,
                  'globals': <built-in function locals>,
                  'len': <built-in function len>,
                  'list': <type 'list'>,
                  'locals': <built-in function locals>,
                  'map': <built-in function map>,
                  'max': <built-in function max>,
                  'min': <built-in function min>,
                  'reduce': <built-in function reduce>,
                  'round': <built-in function round>,
                  'set': <type 'set'>,
                  'str': <type 'str'>,
                  'tuple': <type 'tuple'>}}
(Pdb)

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1065998

Title:
  Workflow Activity "python action" can't use cr, uid, model, ids

Status in OpenERP Server:
  New

Bug description:
  Python actions defined on Workflow Activities don't have available any variables such as cr, uid, ids, etc.
  This can be confirmed by adding to an activite some python code such as:
      print cr, uid

  Digging into the trunk code,  /openerp/workflow/wkf_expr.py (revision
  4485), in _eval_expr() it looks like the variable (cr, uid, model,
  ids) are going to be added to the eval running context.

  But actually that's not the case:

  (Pdb) l
   53                 ret=True
   54             elif line =='False':
   55                 ret=False
   56             else:
   57                 env = Env(cr, uid, model, ids)
   58  ->             ret = eval(line, env, nocopy=True)
   59         return ret
   60
   61     def execute_action(cr, ident, workitem, activity):
   62         obj = pooler.get_pool(cr.dbname).get('ir.actions.server')
   63         ctx = {'active_model':ident[1], 'active_id':ident[2], 'active_ids':[ident[2]]}
  (Pdb) p cr, uid, model, ids
  (<openerp.sql_db.Cursor object at 0x9ace8cc>, 1, 'mgmtsystem.nonconformity', [13])
  (Pdb) pp env
  {'__builtins__': {'False': False,
                    'None': None,
                    'True': True,
                    '__import__': <function _import at 0x89a8374>,
                    'abs': <built-in function abs>,
                    'bool': <type 'bool'>,
                    'dict': <type 'dict'>,
                    'filter': <built-in function filter>,
                    'globals': <built-in function locals>,
                    'len': <built-in function len>,
                    'list': <type 'list'>,
                    'locals': <built-in function locals>,
                    'map': <built-in function map>,
                    'max': <built-in function max>,
                    'min': <built-in function min>,
                    'reduce': <built-in function reduce>,
                    'round': <built-in function round>,
                    'set': <type 'set'>,
                    'str': <type 'str'>,
                    'tuple': <type 'tuple'>}}
  (Pdb)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1065998/+subscriptions


Follow ups

References