summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
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.js31
1 files changed, 17 insertions, 14 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 c16f635a604..39f1be0d107 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1495,7 +1495,8 @@ var BasicModel = AbstractModel.extend({
def = this._rpc({
model: list.model,
method: 'read',
- args: [_.pluck(data, 'id'), fieldNames]
+ args: [_.pluck(data, 'id'), fieldNames],
+ context: record.context,
}).then(function (records) {
_.each(records, function (record) {
list_records[record.id].data = record;
@@ -1743,22 +1744,21 @@ var BasicModel = AbstractModel.extend({
/**
* Fetch all name_gets for the many2ones in a group
*
- * @param {Object} group a valid resource object
+ * @param {Object[]} groups a list of object with context and record sub keys
* @returns {Deferred}
*/
- _fetchMany2OneGroup: function (group) {
- var ids = _.uniq(_.pluck(group, 'res_id'));
-
+ _fetchMany2OneGroup: function (groups) {
+ var ids = _.uniq(_.pluck(_.pluck(groups, 'record'), 'res_id'));
return this._rpc({
- model: group[0].model,
+ model: groups[0].record.model,
method: 'name_get',
args: [ids],
- context: group[0].context
+ context: groups[0].context
})
.then(function (name_gets) {
- _.each(group, function (record) {
- var nameGet = _.find(name_gets, function (n) { return n[0] === record.res_id;});
- record.data.display_name = nameGet[1];
+ _.each(groups, function (obj) {
+ var nameGet = _.find(name_gets, function (n) { return n[0] === obj.record.res_id;});
+ obj.record.data.display_name = nameGet[1];
});
});
},
@@ -2019,14 +2019,17 @@ var BasicModel = AbstractModel.extend({
if (!relatedRecord) {
return;
}
- toBeFetched.push(relatedRecord);
+ toBeFetched.push({
+ context: record.getContext({fieldName: name, viewType: record.viewType}),
+ record: relatedRecord
+ });
}
});
// group them by model and context. Using the context as key is
// necessary to make sure the correct context is used for the rpc;
- var groups = _.groupBy(toBeFetched, function (rec) {
- return [rec.model, JSON.stringify(rec.context)].join();
+ var groups = _.groupBy(toBeFetched, function (elem) {
+ return [elem.record.model, JSON.stringify(elem.context)].join();
});
return $.when.apply($, _.map(groups, this._fetchMany2OneGroup.bind(this)));
@@ -2416,7 +2419,7 @@ var BasicModel = AbstractModel.extend({
model: field.relation,
method: 'read',
args: [ids, fieldNames],
- context: {}, // FIXME
+ context: list.getContext() || {},
});
} else {
def = $.when(_.map(ids, function (id) {