context in form definition not being passed

Bug #1101070 reported by Richard deMeester
26
This bug affects 5 people
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.function(_tff, type='float', string='TFF'),

and in stock/stock_view.xml I have modified the inventory view as follows:

                    <page string="Posted Inventory">
                         <field name="move_ids" context="{'inventory_id':active_id}" >
                            <tree string="Stock Moves">
                                ....
                                ....
                                <field name='tff'/>
                            </tree>
                         </field>
                    </page>

If I debug the _tff method, in version 6.1 the context has the "inventory_id", but in version 7.0, it does not.

Tags: maintenance

Related branches

Changed in openerp-web:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Douglas Baldwin (gdbaldw) wrote :

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.

Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

duplicate of #1091204

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.