[FIX] web: wait for deferreds when actualizing mode

In edit mode, in a *2many with many2many_tags, when adding a new tag when none was set, discarding the form let the new tags displayed while it shouldn't (only a display issue, the tag wasn't added in database)

Fixes #2926
This commit is contained in:
Denis Ledoux 2014-10-13 18:24:57 +02:00
parent 1b49a87619
commit 5e1a5b7dbc
1 changed files with 8 additions and 3 deletions

View File

@ -117,6 +117,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.mutating_mutex = new $.Mutex();
this.on_change_list = [];
this.save_list = [];
this.render_value_defs = [];
this.reload_mutex = new $.Mutex();
this.__clicked_inside = false;
this.__blur_timeout = null;
@ -686,6 +687,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
} else if (mode === "create") {
mode = "edit";
}
this.render_value_defs = [];
this.set({actual_mode: mode});
},
check_actual_mode: function(source, options) {
@ -736,12 +738,15 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
});
},
on_button_cancel: function(event) {
var self = this;
if (this.can_be_discarded()) {
if (this.get('actual_mode') === 'create') {
this.trigger('history_back');
} else {
this.to_view_mode();
this.trigger('load_record', this.datarecord);
$.when.apply(null, this.render_value_defs).then(function(){
self.trigger('load_record', self.datarecord);
});
}
}
this.trigger('on_button_cancel');
@ -2244,7 +2249,7 @@ instance.web.form.ReinitializeWidgetMixin = {
instance.web.form.ReinitializeFieldMixin = _.extend({}, instance.web.form.ReinitializeWidgetMixin, {
reinitialize: function() {
instance.web.form.ReinitializeWidgetMixin.reinitialize.call(this);
this.render_value();
this.view.render_value_defs.push(this.render_value());
},
});
@ -4262,7 +4267,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in
}
};
if (! values || values.length > 0) {
this._display_orderer.add(dataset.name_get(values)).done(handle_names);
return this._display_orderer.add(dataset.name_get(values)).done(handle_names);
} else {
handle_names([]);
}