context in form definition not being passed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Web (MOVED TO GITHUB) |
New
|
Undecided
|
OpenERP Publisher's Warranty Team |
Bug Description
I am sorry if this is in the wrong area (i.e not sure if it is a server or client issue).
This works in version 6.1 but not in version 7.0.
Putting a "context=" on a one2many or many2many in the form definition does not pass the context to the functional fields defined within it.
I have simplified this to a farcical example in an area that appears unchanged between the two revisions.
In stock/stock.py, I have added a functional field to stock.move:
def _tff(self, cr, uid, ids, field_names, arg, context=None):
return dict.fromkeys(ids, 0)
...
'tff': fields.
and in stock/stock_
If I debug the _tff method, in version 6.1 the context has the "inventory_id", but in version 7.0, it does not.
Related branches
- Alexandre Fayolle - camptocamp (community): Needs Fixing (code review, test)
- OpenERP Core Team: Pending requested
-
Diff: 21 lines (+2/-2)1 file modifiedaddons/web/static/src/js/view_form.js (+2/-2)
Changed in openerp-web: | |
assignee: | nobody → OpenERP Publisher's Warranty Team (openerp-opw) |
tags: | added: maintenance |
I can demonstrate that this bug is severe, has two causes, and the most troubling is likely within the web module:
1) The fundamental issue is that context is lost, and this appears to occur within web/http.
2) The second issue is that osv.orm. fields_ view_get( ) fails to extract context from the form.
Demonstration: (requires, import pdb)
A) For the pass through osv.orm. fields_ view_get( ) that needs the referenced context, use pdb to manually inject (view_type + '_view_ref') into context, and the form will render correctly.
B) The pass through osv.orm. fields_ view_get( ) that immediately precedes (A) above should extract (view_type + '_view_ref') from the referencing form, and add this to context, so the referenced context would be available to (A). It does not.
C) However, even if context were injected by fields_view_get() on its first pass (B), this context gets lost before entering the second pass(A) above. I noticed in the call stack from fields_view_get() up to http.py that at some point args are passed by value, not by reference, and I suspect this may be where context is lost.