[FIX] web: translation of default M2O values in search bar

When a many2one field of a searchview was selected
by default, through a default_*_id within the context,
the many2one value name wasn't translated.

e.g. with Spanish loaded (and l10n_multilang installed),
translate a project.project name in Spanish.
Then, while being in Spanish, in the project.project kanban,
click on the Tasks link of a project (tareas),
then, notice the value of the project name in the
search bar.

opw-632818
This commit is contained in:
Denis Ledoux 2015-04-16 12:15:25 +02:00
parent 0d591ca6df
commit 84e10ad03b
2 changed files with 5 additions and 4 deletions

View File

@ -1682,7 +1682,8 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
// to handle this as if it were a single value.
value = value[0];
}
return this.model.call('name_get', [value]).then(function (names) {
var context = instance.web.pyeval.eval('contexts', [this.view.dataset.get_context()]);
return this.model.call('name_get', [value], {context: context}).then(function (names) {
if (_(names).isEmpty()) { return null; }
return facet_from(self, names[0]);
});

View File

@ -292,7 +292,7 @@ openerp.testing.section('search.defaults', {
});
});
test("M2O default: value", {asserts: 5}, function (instance, $s, mock) {
var view = {inputs: []}, id = 4;
var view = {inputs: [], dataset: {get_context: function () {}}}, id = 4;
var f = new instance.web.search.ManyToOneField(
{attrs: {name: 'dummy', string: 'Dummy'}},
{relation: 'dummy.model.name'},
@ -322,7 +322,7 @@ openerp.testing.section('search.defaults', {
});
});
test("M2O default: value array", {asserts: 2}, function (instance, $s, mock) {
var view = {inputs: []}, id = 5;
var view = {inputs: [], dataset: {get_context: function () {}}}, id = 5;
var f = new instance.web.search.ManyToOneField(
{attrs: {name: 'dummy', string: 'Dummy'}},
{relation: 'dummy.model.name'},
@ -344,7 +344,7 @@ openerp.testing.section('search.defaults', {
});
});
test("M2O default: value", {asserts: 1}, function (instance, $s, mock) {
var view = {inputs: []}, id = 4;
var view = {inputs: [], dataset: {get_context: function () {}}}, id = 4;
var f = new instance.web.search.ManyToOneField(
{attrs: {name: 'dummy', string: 'Dummy'}},
{relation: 'dummy.model.name'},