summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2019-09-19 06:19:05 +0000
committerSamuel Degueldre <sad@odoo.com>2019-09-19 08:48:41 +0000
commit16f23e8246db4da4eb34552f360974c2a15f553b (patch)
treea872cb3590d819e6775d4f94f5c60df0232e11fe /addons/web/static/src/js/fields/relational_fields.js
parentfa6dcc7332d964e58aeb9ff6b71f5982f02fa9be (diff)
[FIX] web: fix m2mtags widget to be able to use 'SAVE & NEW'
PURPOSE Previously when the 'SAVE & NEW' button was pressed in the 'create and edit...' menu of the many2many_tags widget was pressed, the modal window would close and the button would act exactly like the 'SAVE & CLOSE' button. This was due to the fact that whenever a new record was created and added to the field, it would reset the many2one field it uses for display, which would destroy the edit modal. This commit fixes that by not notifying the underlying many2one field of any change until the modal is closed by the user. This has the disadvantage that tags display, if visible behind the modal 'shade', will not be updated until the modal is closed, but restores the functionality of the save&new button. It also adds a test for this behaviour task-2070454 closes odoo/odoo#37114 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 1646ef735a2..2a56c6c93e8 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -2286,11 +2286,15 @@ var FieldMany2ManyTags = AbstractField.extend({
this.many2one._getSearchCreatePopupOptions = function (view, ids, context, dynamicFilters) {
var options = _getSearchCreatePopupOptions.apply(this, arguments);
var domain = this.record.getDomain({fieldName: this.name});
+ var m2mRecords = [];
return _.extend({}, options, {
domain: domain.concat(["!", ["id", "in", self.value.res_ids]]),
disable_multiple_selection: false,
on_selected: function (records) {
- self.many2one.reinitialize(records);
+ m2mRecords.push(...records);
+ },
+ on_closed: function () {
+ self.many2one.reinitialize(m2mRecords);
},
});
};