From 67747e6fa5f4c1b27eed5dfd7231001e98fb34c1 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 2 Jun 2017 15:35:29 +0200 Subject: [FIX] web: FieldOne2Many: re-activate 'Add an item' The 'Add an item' button of one2many editable lists is deactivated once clicked (since rev. f9a1241) to prevent concurrent record creation. It is re-activated when the record has been created. Unfortunately, it might happen that the record is actually not created, so in this case the button is never re-activated. This happens for example on the customer invoice form view, if the user tries to add a line before selecting a partner. --- addons/web/static/src/js/fields/relational_fields.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index e13c3d29004..e9af73c1343 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -964,7 +964,6 @@ var FieldOne2Many = FieldX2Many.extend({ var index = self.editable === 'top' ? 0 : self.value.data.length - 1; var newID = self.value.data[index].id; self.renderer.editRecord(newID); - self.creatingRecord = false; } } }); @@ -1014,6 +1013,7 @@ var FieldOne2Many = FieldX2Many.extend({ * in the kanban view */ _onAddRecord: function (ev) { + var self = this; // we don't want interference with the components upstream. ev.stopPropagation(); @@ -1023,10 +1023,11 @@ var FieldOne2Many = FieldX2Many.extend({ this._setValue({ operation: 'CREATE', position: this.editable, + }).always(function () { + self.creatingRecord = false; }); } } else { - var self = this; this._openFormDialog({ on_saved: function (record) { self._setValue({ operation: 'ADD', id: record.id }); -- cgit v1.2.3