[FIX] domain returned by onchange
The "new" form engine performs a bunch of conversions on the form arch from json to xml to text to json again (or something), thus the ``node`` attribute on form fields might be json but it's got no more relation to the form's own arch (and the fields defined therein). Meanwhile the domains processing for onchange recursively traversed the *form*'s arch trying to find a node matching the key it had to set its @domain to what it was given. It long predates the "new" form engine, and since it alters the *original* arch not a copy the "new" form engine broke it. And since that's untested, it's been broken for a bunch of months (probably). Fix by looking up the field according to the domain key (in form.fields), and setting the domain in the node of the field, rather than the node of the form's arch. lp bug: https://launchpad.net/bugs/1088447 fixed bzr revid: xmo@openerp.com-20130124144018-0g3sl2nej2aj6syp
This commit is contained in:
parent
611ff620ce
commit
e761ab7454
|
@ -573,19 +573,14 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
]
|
||||
});
|
||||
}
|
||||
if (result.domain) {
|
||||
function edit_domain(node) {
|
||||
if (typeof node !== "object") {
|
||||
return;
|
||||
}
|
||||
var new_domain = result.domain[node.attrs.name];
|
||||
if (new_domain) {
|
||||
node.attrs.domain = new_domain;
|
||||
}
|
||||
_(node.children).each(edit_domain);
|
||||
}
|
||||
edit_domain(this.fields_view.arch);
|
||||
}
|
||||
|
||||
var fields = this.fields;
|
||||
_(result.domain).each(function (domain, fieldname) {
|
||||
var field = fields[fieldname];
|
||||
if (!field) { return; }
|
||||
field.node.attrs.domain = domain;
|
||||
});
|
||||
|
||||
return $.Deferred().resolve();
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
|
|
Loading…
Reference in New Issue