summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2014-09-04 17:21:12 +0200
committerDenis Ledoux <dle@odoo.com>2014-09-04 17:22:04 +0200
commit82adba4714d9b809aad835d0d77e6b6f9fde8ddc (patch)
tree04a6c59dbd3212f7414312db6127b4aae832495b /addons/web/static/src
parent80a932479b8a49ca716f017f80fdb0984b10adb3 (diff)
[FIX] web: wait onchanges to be processed before save
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/view_form.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 9fe8dd5a7c5..3fa9afea0bc 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -103,6 +103,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.fields_order = [];
this.datarecord = {};
this._onchange_specs = {};
+ this.onchanges_defs = [];
this.default_focus_field = null;
this.default_focus_button = null;
this.fields_registry = instance.web.form.widgets;
@@ -507,7 +508,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
def = self.alive(new instance.web.Model(self.dataset.model).call(
"onchange", [ids, values, trigger_field_name, onchange_specs, context]));
}
- return def.then(function(response) {
+ var onchange_def = def.then(function(response) {
if (widget && widget.field['change_default']) {
var fieldname = widget.name;
var value_;
@@ -543,6 +544,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}).then(function(response) {
return self.on_processed_onchange(response);
});
+ this.onchanges_defs.push(onchange_def);
+ return onchange_def;
} catch(e) {
console.error(e);
instance.webclient.crashmanager.show_message(e);
@@ -642,6 +645,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
* if the current record is not yet saved. It will then stay in create mode.
*/
to_edit_mode: function() {
+ this.onchanges_defs = [];
this._actualize_mode("edit");
},
/**
@@ -790,12 +794,14 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var self = this;
var save_obj = {prepend_on_create: prepend_on_create, ret: null};
this.save_list.push(save_obj);
- return this._process_operations().then(function() {
- if (save_obj.error)
- return $.Deferred().reject();
- return $.when.apply($, save_obj.ret);
- }).done(function() {
- self.$el.removeClass('oe_form_dirty');
+ return $.when.apply($, self.onchanges_defs).then(function(){
+ return self._process_operations().then(function() {
+ if (save_obj.error)
+ return $.Deferred().reject();
+ return $.when.apply($, save_obj.ret);
+ }).done(function() {
+ self.$el.removeClass('oe_form_dirty');
+ });
});
},
_process_save: function(save_obj) {