diff options
| author | Sébastien Theys <seb@odoo.com> | 2018-06-07 15:55:54 +0200 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2018-06-29 10:39:42 +0200 |
| commit | 217fee2636fb4dc4c193e67e5727a9fcef200605 (patch) | |
| tree | d1467195d08c56b45d20d063dc95bc94b1e3ff7e /addons/web/static/src/js/views/basic | |
| parent | 13667b0dff24449d3c8f9acb33a2153b16c01de7 (diff) | |
[FIX] web: prevent RPC from failing if no route is set
The scenario is:
- create a new parent model, which has a one2many
- add at least 2 one2many lines which have:
- a handle field
- a many2one, which is not required, and we will leave it empty
- reorder the lines with the handle
This will call a resequence, which calls a name_get.
With the bug that would throw an error at the RPC, but this commit fixes it.
Diffstat (limited to 'addons/web/static/src/js/views/basic')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 16 |
1 files changed, 15 insertions, 1 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 cf3c08128ce..ae9f0611abf 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1984,9 +1984,20 @@ var BasicModel = AbstractModel.extend({ dataPoint.data.display_name = result[0][1]; }); }, + /** + * Fetch name_get for a field of type Many2one or Reference + * + * @private + * @params {Object} list: must be a datapoint of type list + * (for example: a datapoint representing a x2many) + * @params {string} fieldName: the name of a field of type Many2one or Reference + * @returns {Deferred} + */ _fetchNameGets: function (list, fieldName) { var self = this; - var model; + // We first get the model this way because if list.data is empty + // the _.each below will not make it. + var model = list.fields[fieldName].relation; var records = []; var ids = []; list = this._applyX2ManyOperations(list); @@ -1999,8 +2010,11 @@ var BasicModel = AbstractModel.extend({ var many2oneRecord = self.localData[many2oneId]; records.push(many2oneRecord); ids.push(many2oneRecord.res_id); + // We need to calculate the model this way too because + // field .relation is not set for a reference field. model = many2oneRecord.model; }); + if (!ids.length) { return $.when(); } |
