From 0eaaeb68bc28917f86f7cfe646d2512dac54cc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 23 May 2016 13:16:39 +0200 Subject: [PATCH] [FIX] web: better blur handling in m2m in wizards Before this commit, many2many list views in wizards did not handle the blur event at all, which means that the last edited line was ignored. This is quite a large bug, but not really visible in our standard install, because we had no many2many in wizards. This commit add naive support for blur events. This is only intended to help the MRP team. A complete solution would probably involve moving most of the code in One2ManyListView to X2ManyListView. --- .../src/js/views/form_relational_widgets.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index 8e64599f470..ce64380f391 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -1277,6 +1277,8 @@ var Many2ManyListView = X2ManyListView.extend({ this.options = _.extend(this.options, { ListType: X2ManyList, }); + this.on('edit:after', this, this.proxy('_after_edit')); + this.on('save:before cancel:before', this, this.proxy('_before_unedit')); }, do_add_record: function () { var self = this; @@ -1323,6 +1325,20 @@ var Many2ManyListView = X2ManyListView.extend({ }); } }, + _after_edit: function () { + this.editor.form.on('blurred', this, this._on_blur_many2many); + }, + _before_unedit: function () { + this.editor.form.off('blurred', this, this._on_blur_many2many); + }, + _on_blur_many2many: function() { + return this.save_edition().done(function () { + if (self._dataset_changed) { + self.dataset.trigger('dataset_changed'); + } + }); + }, + }); var FieldMany2Many = FieldX2Many.extend({