From cdb0601417a1e114bec809a3082491dbc008cd67 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 23 Oct 2012 14:59:57 +0200 Subject: [PATCH] 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, {