[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.
This commit is contained in:
Géry Debongnie
2016-05-23 13:53:05 +02:00
parent 90130744e0
commit 0eaaeb68bc
@@ -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({