~openerp-dev/openobject-client-web/6.0-opw-587800-2-cpa

« back to all changes in this revision

Viewing changes to addons/openerp/static/javascript/m2m.js

  • Committer: Xavier ALT
  • Date: 2012-11-29 09:17:53 UTC
  • mfrom: (4890.1.2 6.0-opw-581451-xal)
  • Revision ID: xal@openerp.com-20121129091753-m0tog8k2ks7w6yl8
[MERGE] OPW 581451: one2many, editable tree view: fix onchange trigger using parent.* reference on 'New' record

  * on new record creation in 'editable' tree view, fix client side code to
    correctly triggers on_change for field having default value. Before we were
    trying to do that server-side, but we are missing 'parent' values - so
    on_change call might return wrong results.

  * m2m: fix double on_change call when calling m2m's 'onChange' function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
 
73
73
        // save the reference
74
74
        openobject.dom.get(name)._m2m = this;
 
75
 
 
76
        var $this = jQuery(idSelector('_m2m_' + name));
 
77
        var $list = jQuery(idSelector(name));
 
78
        $list.attr({
 
79
            'callback': $this.attr('callback'),
 
80
            'change_default': $this.attr('change_default')
 
81
        });
 
82
        $list.bind('before-redisplay.m2m', function () {
 
83
            // calls form.js onChange()
 
84
            onChange(name);
 
85
        });
 
86
 
75
87
    },
76
88
 
77
89
    onChange: function() {
78
 
        this.setValue(this.id.value);
 
90
        this.setValue(this.id.value, {'no_onchange': true});
79
91
    },
80
92
 
81
93
    selectAll: function() {
84
96
        }
85
97
    },
86
98
 
87
 
    setValue: function(ids) {
 
99
    setValue: function(ids, options) {
 
100
        var options = options || {};
88
101
        ids = /^\[.*\]/.test(ids) ? ids : '[' + ids + ']';
89
102
        ids = eval(ids);
90
103
 
97
110
            jQuery(idSelector(this.name)).val(ids);
98
111
        }
99
112
 
100
 
        if ($id.attr('callback')) {
 
113
        if ($id.attr('callback') && !options.no_onchange) {
101
114
            onChange(this.id);
102
115
        }
103
116
        // Mark form as changed so save alert can appear