[FIX] web: give context to fetch x2m batched
Before this commit M2Mtags widget did not translate. This was because no context was given to the rpc that fetched the fields Hence, the lang was not passed. After this commit, M2Mtags translate well OPW 784396
This commit is contained in:
@@ -1480,7 +1480,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;
|
||||
@@ -2399,7 +2400,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) {
|
||||
|
||||
@@ -8055,7 +8055,7 @@ QUnit.module('relational_fields', {
|
||||
});
|
||||
|
||||
QUnit.test('fieldmany2many tags in editable list', function (assert) {
|
||||
assert.expect(4);
|
||||
assert.expect(7);
|
||||
|
||||
this.data.partner.records[0].timmy = [12];
|
||||
|
||||
@@ -8063,10 +8063,18 @@ QUnit.module('relational_fields', {
|
||||
View: ListView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
context: {take: 'five'},
|
||||
arch:'<tree editable="bottom">' +
|
||||
'<field name="foo"/>' +
|
||||
'<field name="timmy" widget="many2many_tags"/>' +
|
||||
'</tree>',
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'read' && args.model === 'partner_type') {
|
||||
assert.deepEqual(args.kwargs.context, {take: 'five'},
|
||||
'The context should be passed to the RPC');
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
assert.strictEqual(list.$('.o_data_row:first .o_field_many2manytags .badge').length, 1,
|
||||
|
||||
Reference in New Issue
Block a user