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

Bug #1065998 reported by Daniel Reis
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP's Framework R&D

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)

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Why this is a WishList?

Revision history for this message
Stefano Gattuso (g-info-c) wrote :

There is some news about this?
i am tring to use this :
write({'x_invoice_pf_number':pool.get('ir.sequence').get(cr, uid,'invoice.proforma')})
but cr and uid is not recognized

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.