From 823cfd6ab1b30c0f86acd18e1de98c9bc988594d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 20 Oct 2017 10:53:46 +0200 Subject: [FIX] web: make sure m2m_checkbox works twice in a row We had an interesting bug with the field many2many_checkbox: in some cases, it could cause a crash, because it could not find an element in the localdata. To reproduce this, start with a non empty field many2many checkbox, then uncheck them twice. The reason is that the datapoint of type 'list' that represents the current value is actually modified, and the replace_with operation assumed that it could find the localID by looking into its data. I have the feeling that a more complete fix is to make sure that the datapoint is not modified (in its 'data' key), but is modified in its '_changes' key. However, this would probably be a bigger change. --- addons/web/static/src/js/views/basic/basic_model.js | 3 +++ 1 file changed, 3 insertions(+) (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 3591ac3cf94..b4a0b999453 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1541,6 +1541,9 @@ var BasicModel = AbstractModel.extend({ removedDef = this._applyX2ManyChange(record, fieldName, { operation: 'DELETE', ids: _.map(removedIds, function (resID) { + if (resID in list._cache) { + return list._cache[resID]; + } return _.findWhere(listData, {res_id: resID}).id; }), }); -- cgit v1.2.3