Merge lp:~openerp-dev/openerp-web/7.0-opw-584668-cpa into lp:openerp-web/7.0

Proposed by Chirag Patel (OpenERP)
Status: Rejected
Rejected by: Olivier Dony (Odoo)
Proposed branch: lp:~openerp-dev/openerp-web/7.0-opw-584668-cpa
Merge into: lp:openerp-web/7.0
Diff against target: 21 lines (+2/-2)
1 file modified
addons/web/static/src/js/view_form.js (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-opw-584668-cpa
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp (community) code review, test Needs Fixing
OpenERP Core Team Pending
Review via email: mp+145363@code.launchpad.net

Description of the change

Hello,

Reproduce Issue: check the related bug #1101070 description.

Thanks

To post a comment you must log in.
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

It seems that the bug was fixed by revision 3849 of openerp-web 7.0, related to bug 1091204.
Please provide more information if the problem is not solved completely. Thanks!

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

I'm facing a very similar bug to lp:1088842 and this patch does fix the issue, which occurs even with revision 3849 of openerp-web.

To reproduce the issue :

1. create two models, testmodel and testmodel.line each with a name attribute
2. add a line_ids one2many relation to testmodel with the corresponding many2one relation in testmodel.line
3. add a function field to testmodel.line defined as:

class testmodel_line(orm.Model):
    def _fnc_reproduce(self, cr, uid, ids, field_name, arg, context=None):
        if context is None:
            context = {}
        assert 'new_key' in context
        return context['new_key']

    _columns = {'reproduce': fields.function(_fnc_reproduce, type='char', method=True, string='Reproduce bug')}

4. define a view for testmodel as:

    <record id="testmodel_form" model="ir.ui.view">
      <field name="name">testmodel form</field>
      <field name="model">testmodel</field>
      <field name="arch" type="xml">
        <form version="7.0" string="Test Model">
        <sheet>
          <group col="2">
            <field name="name">
            <field name='line_ids' context="{'new_key': 'new key value'}">
              <tree version="7.0" string="Area information" editable="bottom">
                <field name="name"/>
                <field name="reproduce"/>
              </tree>
            </field>
          </group>
        </sheet>
       </form>
      </field>
    </record>

Display the form view, create an entry, you should get a crash because of the lack of the key in the context passed to the function field.

BTW this is very close to the description of lp:1101070, which leads me to think that this bug is in fact different from lp:1091204.

I'm about to prepare a MP for OCB.

review: Approve (code review, test)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

OTOH, this branch breaks stuff: with the branch applied, I get errors when displaying the form view of res.partner :

in:

                        <field name="parent_id"
                            placeholder="Company"
                            domain="[('is_company', '=', True)]" context="{'default_is_company': True, 'default_supplier': supplier}"
                            attrs="{'invisible': [('is_company','=', True),('parent_id', '=', False)]}"
                            on_change="onchange_address(use_parent_address, parent_id)"/>

the evaluation of the context in javascript fails because supplier is not defined.

review: Needs Fixing (code review, test)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

reported https://bugs.launchpad.net/openerp-web/+bug/1217374 with everything needed to reproduce the issues.

Unmerged revisions

3730. By Chirag Patel (OpenERP)

[FIX] Fixed o2m or m2m in the form definition does not pass the context to the function fields.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/view_form.js'
2--- addons/web/static/src/js/view_form.js 2013-01-24 14:40:18 +0000
3+++ addons/web/static/src/js/view_form.js 2013-01-29 13:16:33 +0000
4@@ -3360,7 +3360,7 @@
5 this.form_last_update = $.Deferred();
6 this.init_form_last_update = this.form_last_update;
7 this.is_started = false;
8- this.dataset = new instance.web.form.One2ManyDataSet(this, this.field.relation);
9+ this.dataset = new instance.web.form.One2ManyDataSet(this, this.field.relation, this.build_context());
10 this.dataset.o2m = this;
11 this.dataset.parent_view = this.view;
12 this.dataset.child_name = this.name;
13@@ -4108,7 +4108,7 @@
14 init: function(field_manager, node) {
15 this._super(field_manager, node);
16 this.is_loaded = $.Deferred();
17- this.dataset = new instance.web.form.Many2ManyDataSet(this, this.field.relation);
18+ this.dataset = new instance.web.form.Many2ManyDataSet(this, this.field.relation, this.build_context());
19 this.dataset.m2m = this;
20 var self = this;
21 this.dataset.on('unlink', self, function(ids) {