diff options
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.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(); } |
