From 16eb262c60a3b46f89cb706504a8c2d3dc755e08 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Fri, 29 Sep 2017 14:01:51 +0200 Subject: [FIX] web: fix one2many default get The one2many default get code used to meddle with basic_model's res_ids manually, which ended up desynchronizing the data and res_ids fields of the list representation of the one2many values. This commit solves the issue by using the proper mechanisms of the basic_model, that is creating a proper datapoint for those ids. Steps to reproduce the original issue: - Install sale_mamangement, mrp and purchase - Create a product - In the Inventory tab, in Routes, uncheck Buy - Check and then uncheck back any other route than Buy - Get a traceback because we are looking for a record with a given res_id in the list data but since they are desynchronized, data is empty at that point even though res_ids is not. --- addons/web/static/src/js/views/basic/basic_model.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 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 7810a1195f0..9e7fb8b78ef 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3182,8 +3182,18 @@ var BasicModel = AbstractModel.extend({ } if (value[0] === 6) { // REPLACE_WITH - x2manyList.res_ids = value[2]; - x2manyList.count = x2manyList.res_ids.length; + _.each(value[2], function (res_id) { + r = self._makeDataPoint({ + modelName: x2manyList.model, + context: x2manyList.context, + fieldsInfo: fieldsInfo, + fields: fields, + parentID: x2manyList.id, + res_id: res_id, + viewType: viewType, + }); + x2manyList._changes.push({operation: 'ADD', id: r.id}); + }); var def = self._readUngroupedList(x2manyList).then(function () { return $.when( self._fetchX2ManysBatched(x2manyList), -- cgit v1.2.3