From a0217f4475b02660fc687d154f1287029ed0e23d Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Fri, 12 May 2017 13:22:01 +0200 Subject: [FIX] web: BasicModel: update parent data after record deletion After the record deletion, the parent should be updated to take the deletion into account. This was causing an issue in the Kanban view: after a column deletion, it appeared again if you created a new one. --- .../web/static/src/js/views/basic/basic_model.js | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (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 ca042d63d69..f6c4d6ea23b 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -180,15 +180,16 @@ var BasicModel = AbstractModel.extend({ }); }, /** - * Delete a list of records, then, if a parentID is given, reload the - * parent. + * Delete a list of records, then, if the records have a parent, reload it. * * @todo we should remove the deleted records from the localData - * @todo why can't we infer modelName? + * @todo why can't we infer modelName? Because of grouped datapoint + * --> res_id doesn't correspond to the model and we don't have the + * information about the related model * * @param {string[]} recordIds list of local resources ids. They should all - * be of type 'record', and of the same model - * @param {string} modelName + * be of type 'record', be of the same model and have the same parent. + * @param {string} modelName mode name used to unlink the records * @returns {Deferred} */ deleteRecords: function (recordIds, modelName) { @@ -202,9 +203,15 @@ var BasicModel = AbstractModel.extend({ }) .then(function () { _.each(records, function (record) { - record.res_ids.splice(record.offset, 1); - record.res_id = record.res_ids[record.offset]; - record.count--; + var parent = record.parentID && self.localData[record.parentID]; + if (parent && parent.type === 'list') { + parent.data = _.without(parent.data, record.id); + delete self.localData[record.id]; + } else { + record.res_ids.splice(record.offset, 1); + record.res_id = record.res_ids[record.offset]; + record.count--; + } }); }); }, -- cgit v1.2.3