From 130c47bc0abee1ab193fb136bd1844dba8a693cd Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 20 Sep 2017 14:45:23 +0200 Subject: [FIX] web: several minor issues with editable list - correctly update the pager when a record is added or removed - destroy the widgets of the removed row when the user clicks on 'Cancel' when creating a new record - ensure that the list always contains 4 rows (before this rev., in list views with less than 4 records, if the user created a new record, then clicked on 'Discard', there were only 3 rows left - properly destroy field widgets when removed from the DOM Note that the change of parent.parentID to parent.static is not a bug fix, but it's better to use the key that indicates the type of list element, instead of implying it from other attributes. --- addons/web/static/src/js/views/basic/basic_model.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index cf5a18488a6..103c0d4c5d2 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -768,7 +768,7 @@ var BasicModel = AbstractModel.extend({ removeLine: function (elementID) { var record = this.localData[elementID]; var parent = this.localData[record.parentID]; - if (parent.parentID) { + if (parent.static) { // x2Many case: the new record has been stored in _changes, as a // command so we remove the command(s) related to that record parent._changes = _.filter(parent._changes, function (change) { @@ -777,6 +777,7 @@ var BasicModel = AbstractModel.extend({ } else { // main list view case: the new record is in data parent.data = _.without(parent.data, elementID); + parent.count--; } }, /** -- cgit v1.2.3