diff options
| author | David Monjoie <dmo@odoo.com> | 2017-09-29 14:01:51 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-09-30 09:04:29 +0200 |
| commit | 8d1630a40adbac8f9cd70a8ef0e7b9b61b7a60e8 (patch) | |
| tree | 43c5ea56e00120eceb75b09ccdedf0487096da7f /addons/web/static/src | |
| parent | e4672db97da1df7c297aafbea93b9ffa26da5e4e (diff) | |
[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.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 14 |
1 files changed, 12 insertions, 2 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 103c0d4c5d2..8291e798904 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3158,8 +3158,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), |
