summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2017-05-12 13:22:01 +0200
committerMartin Geubelle <mge@odoo.com>2017-05-15 14:55:21 +0200
commita0217f4475b02660fc687d154f1287029ed0e23d (patch)
tree6c588b4fbbe7d8daa94f3ea99e77c36024c4e0e5 /addons/web/static/src/js/views/basic/basic_model.js
parent2fb4cf46d23149aabbc1a03791d27430fc6b9ce1 (diff)
[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.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js23
1 files changed, 15 insertions, 8 deletions
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--;
+ }
});
});
},