Context is not transfered to one2many fields_view_get anymore

Bug #1088842 reported by Xavier Fernandez http://www.smile.fr
94
This bug affects 19 people
Affects Status Importance Assigned to Milestone
Odoo Web (MOVED TO GITHUB)
Confirmed
Undecided
Unassigned
OpenERP Community Backports (Web)
New
Undecided
Unassigned

Bug Description

On trunk.
In a form view with a one2many with a context, like this:
<field name="line_ids" colspan="4" nolabel="1" context="{'start_period_id': start_period_id, 'tree_view_ref': 'smile_mps.view_mps_procurement_planning_line_tree1'}" modifiers="{}"/>

In rev 3563, that's what we had in fields_view_get context:
{'lang': 'fr_FR', 'tree_view_ref': 'smile_mps.view_mps_procurement_planning_line_tree1', 'tz': 'Europe/Brussels', 'uid': 1, 'start_period_id': 36}

But now in rev 3587 (and since rev 3564), that's what we have:
{'lang': 'fr_FR', 'tz': 'Europe/Brussels', 'uid': 1}

Related branches

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

I am experiencing the same bug on an up-to-date OpenERP 7.0... we really need a fix for this !

Revision history for this message
Jean-Michel (jeanmichel-awad) wrote :
Carlos Pueyo (cpueyo)
Changed in openerp-web:
status: New → Confirmed
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

This bug is really annoying, because it's a regression compared to OpenERP 6.1. Does a workaround exist ?

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : Re: [Bug 1088842] Re: Context is not transfered to one2many fields_view_get anymore

Hello Alexis and others,

did you check also also this one https://bugs.launchpad.net/bugs/1091204 ?
Isn't one the duplicate of the other?
That doesn't help to fix things, but eventually that highlights the
importance of the regression if that ever matters.

On Mon, Mar 18, 2013 at 2:04 PM, Alexis de Lattre <email address hidden> wrote:

> This bug is really annoying, because it's a regression compared to
> OpenERP 6.1. Does a workaround exist ?
>
> --
> You received this bug notification because you are a member of OpenERP
> Drivers, which is subscribed to OpenERP Web.
> https://bugs.launchpad.net/bugs/1088842
>
> Title:
> Context is not transfered to one2many fields_view_get anymore
>
> Status in OpenERP Web:
> Confirmed
>
> Bug description:
> On trunk.
> In a form view with a one2many with a context, like this:
> <field name="line_ids" colspan="4" nolabel="1"
> context="{'start_period_id': start_period_id, 'tree_view_ref':
> 'smile_mps.view_mps_procurement_planning_line_tree1'}" modifiers="{}"/>
>
> In rev 3563, that's what we had in fields_view_get context:
> {'lang': 'fr_FR', 'tree_view_ref':
> 'smile_mps.view_mps_procurement_planning_line_tree1', 'tz':
> 'Europe/Brussels', 'uid': 1, 'start_period_id': 36}
>
> But now in rev 3587 (and since rev 3564), that's what we have:
> {'lang': 'fr_FR', 'tz': 'Europe/Brussels', 'uid': 1}
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openerp-web/+bug/1088842/+subscriptions
>

Revision history for this message
Tanel Külaots (mou) wrote :

Hello,

even after revision 3850 this bug is still there so unfortunately it's not a duplicate.
I managed to "fix" it like that:

=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2013-04-09 12:28:52 +0000
+++ addons/web/static/src/js/view_form.js 2013-04-10 08:00:04 +0000
@@ -3472,7 +3472,7 @@
         this.form_last_update = $.Deferred();
         this.init_form_last_update = this.form_last_update;
         this.is_started = false;
- this.dataset = new instance.web.form.One2ManyDataSet(this, this.field.relation);
+ this.dataset = new instance.web.form.One2ManyDataSet(this, this.field.relation, this.build_context());
         this.dataset.o2m = this;
         this.dataset.parent_view = this.view;
         this.dataset.child_name = this.name;

It's probably not correct nor suffiecent, but at least makes my code run. Someone with more understanding of this javascript mess should probably tell me why it's wrong to do it this way...

Revision history for this message
Tanel Külaots (mou) wrote :

I also found that this bug is fixed in https://code.launchpad.net/~openerp-dev/openerp-web/7.0-opw-584668-cpa but not merged into trunk/7.0 yet.

Revision history for this message
PabloCM (pablocm) wrote :

I have found this same problem with tree views too, is there any kind of workaround for these?

Revision history for this message
Stefan Reisich (nafex) wrote :

Any news on this? When i apply the fix manually on newest 7.0 and edit a customer i get a error message saying "Uncaught Error: NameError: name 'supplier' is not defined".

Revision history for this message
Egor Tsinko (etsinko) wrote :

I'm having same problems as Stefan has. After applying the proposed fix my Customers view is broken. I get the same error: "Uncaught Error: NameError: name 'supplier' is not defined"

Revision history for this message
Stefan Reisich (nafex) wrote :

why this annoying bug is not fixed???

Revision history for this message
Dércio Duvane (daduvane) wrote :

The fix provided by Tanel Külaots (mou) seems to work, but I have another question. On version 6.1, this fix works great but it is not possible to set the context on a one2many row and use it on the next row. Is there a patch/fix for this case?

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

I also confirm that the patch proposed by Tanel Külaots in comment #5 works well.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hi,

This seems a duplicate of bug 1091204 that is marked as fixed. Could you check that you still get the error after revision 3849 (rev-id <email address hidden>) of openerp-web 7.0?
If you do, please post more details on bug 1091204 with an updated test case.

It seems to work for me on revision 3941:

  I modifying the sales order form as follows:
   <field name="order_line" context="{'tree_view_ref': 'sale.view_order_line_tree', 'foo': partner_id}">

  And I get the following context passed to sale.order.line.fields_view_get():
   {'lang': 'en_US', 'tree_view_ref': 'sale.view_order_line_tree', 'tz': 'Europe/Brussels', 'uid': 1, 'foo': 15}

Thanks!

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

@Carlos Pueyo: thanks for confirming that you could reproduce the bug, however I'm afraid your partial processing of the bug report made it escape our radar. Please see our documentation [1] for more information regarding bug processing. Thanks!

[1] https://doc.openerp.com/7.0/contribute/11_bug_tracker/#bug-qualification

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

In fact, my test scenario was not the same as the one described by Xavier, and it seems that I was expecting too much of what you are supposed to get when context is passed in a one2many.

So Olivier was right when closing this bug. I found another way to do what I wanted to do without using context is one2many.

Revision history for this message
Andrea Cometa (scigghia) wrote :

the patch worked for me, thanks
why this merge proposal has been rejected?!

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.