summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2015-02-09 17:35:17 +0100
committerRaphael Collet <rco@openerp.com>2015-02-10 13:12:40 +0100
commit2067a206ecba9a8dbf7f76a55926be964e580e7e (patch)
tree923f3f709fc63cf9ae7dc7a3aab67c77ed058e0e /addons/web/static/src
parent372f4a82d5c4e4081953fbd2ee9654f9ae301f80 (diff)
[FIX] models: process onchange methods on new records in the order of the view
The onchange() on new records processes fields in non-predictable order. This is problematic when onchange methods are designed to be applied after each other. The expected order is presumed to be the one of the fields in the view. In order to implement this behavior, the JS client invokes method onchange() with the list of fields (in view order) instead of False. The server then uses that order for evaluating the onchange methods. This fixes #4897.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/view_form.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 6aba8c5dc50..996034f7ebe 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -452,8 +452,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
return "";
};
+ self._onchange_fields = [];
self._onchange_specs = {};
_.each(this.fields, function(field, name) {
+ self._onchange_fields.push(name);
self._onchange_specs[name] = find(name, field.node);
_.each(field.field.views, function(view) {
_.each(view.fields, function(_, subname) {
@@ -490,7 +492,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var change_spec = widget ? onchange_specs[widget.name] : null;
if (!widget || (!_.isEmpty(change_spec) && change_spec !== "0")) {
var ids = [],
- trigger_field_name = widget ? widget.name : false,
+ trigger_field_name = widget ? widget.name : self._onchange_fields,
values = self._get_onchange_values(),
context = new instance.web.CompoundContext(self.dataset.get_context());