From 8e7ec0974960455d8fec16d92b8e4e93ea2aaa0e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 22 Oct 2012 18:15:16 +0200 Subject: [PATCH 1/3] m bzr revid: nicolas.vanhoren@openerp.com-20121022161516-4g9wg1a3fv0r7t12 --- addons/web/static/src/js/view_form.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 850a334c40b..bd4f8f5d55f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3234,6 +3234,12 @@ var commands = { return [6, false, ids]; } }; +/** + widget options: + - reload_on_button: Reload the whole form view if click on a button in a list view. + If you see this options, do not use it, it's basically a dirty hack to make one + precise o2m to behave the way we want. +*/ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ multi_selection: false, disable_utility_classes: true, @@ -3689,7 +3695,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ readonly: !this.is_action_enabled('edit') || self.o2m.get("effective_readonly") }); }, - do_button_action: function (name, id, callback) { + handle_button: function(name, id, call) { + var _sup = _.bind(this._super, this); if (!_.isNumber(id)) { instance.webclient.notification.warn( _t("Action Button"), @@ -3700,14 +3707,22 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ var self = this; this.ensure_saved().pipe(function () { if (parent_form) - return parent_form.save(); + return parent_form.recursive_save(); else return $.when(); - }).then(function () { - self.handle_button(name, id, callback); + }).pipe(function () { + var call; + debugger; + if (! self.o2m.options.reload_on_button) { + call = callback; + } else { + call = function() { + self.o2m.view.recursive_reload(); + }; + } + _sup(name, id, call); }); }, - _before_edit: function () { this.__ignore_blur = false; this.editor.form.on('blurred', this, this._on_form_blur); From 94bc60b31027c36f94d6f07c3a485f4d355b673e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 23 Oct 2012 14:52:13 +0200 Subject: [PATCH 2/3] reverted changes to o2m bzr revid: nicolas.vanhoren@openerp.com-20121023125213-d7nc1282zmbvk72a --- addons/web/static/src/js/view_form.js | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ce6be5b2305..bd2fed78042 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3234,12 +3234,6 @@ var commands = { return [6, false, ids]; } }; -/** - widget options: - - reload_on_button: Reload the whole form view if click on a button in a list view. - If you see this options, do not use it, it's basically a dirty hack to make one - precise o2m to behave the way we want. -*/ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ multi_selection: false, disable_utility_classes: true, @@ -3695,8 +3689,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ readonly: !this.is_action_enabled('edit') || self.o2m.get("effective_readonly") }); }, - handle_button: function(name, id, call) { - var _sup = _.bind(this._super, this); + do_button_action: function (name, id, callback) { if (!_.isNumber(id)) { instance.webclient.notification.warn( _t("Action Button"), @@ -3707,22 +3700,14 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ var self = this; this.ensure_saved().pipe(function () { if (parent_form) - return parent_form.recursive_save(); + return parent_form.save(); else return $.when(); - }).pipe(function () { - var call; - debugger; - if (! self.o2m.options.reload_on_button) { - call = callback; - } else { - call = function() { - self.o2m.view.recursive_reload(); - }; - } - _sup(name, id, call); + }).then(function () { + self.handle_button(name, id, callback); }); }, + _before_edit: function () { this.__ignore_blur = false; this.editor.form.on('blurred', this, this._on_form_blur); From cdb0601417a1e114bec809a3082491dbc008cd67 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 23 Oct 2012 14:59:57 +0200 Subject: [PATCH 3/3] got it bzr revid: nicolas.vanhoren@openerp.com-20121023125957-lfs7yogbygw2uz4a --- addons/web/static/src/js/view_form.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index bd2fed78042..72d9725e105 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3987,9 +3987,12 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in }, }); -/* - * TODO niv: clean those deferred stuff, it could be better - */ +/** + widget options: + - reload_on_button: Reload the whole form view if click on a button in a list view. + If you see this options, do not use it, it's basically a dirty hack to make one + precise o2m to behave the way we want. +*/ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({ multi_selection: false, disable_utility_classes: true, @@ -4118,7 +4121,20 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in readonly: this.getParent().get("effective_readonly") }); pop.on('write_completed', self, self.reload_content); - } + }, + do_button_action: function(name, id, callback) { + var self = this; + var _sup = _.bind(this._super, this); + if (! this.m2m_field.options.reload_on_button) { + return _sup(name, id, callback); + } else { + return this.m2m_field.view.save().pipe(function() { + return _sup(name, id, function() { + self.m2m_field.view.reload(); + }); + }); + } + }, }); instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(instance.web.form.CompletionFieldMixin, {