diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js index b1cbe86d5fa..3009edd4c78 100644 --- a/addons/board/static/src/js/dashboard.js +++ b/addons/board/static/src/js/dashboard.js @@ -10,6 +10,7 @@ var FormController = require('web.FormController'); var FormRenderer = require('web.FormRenderer'); var FormView = require('web.FormView'); var pyUtils = require('web.pyeval'); // do not forwardport this to 12.0 +var session = require('web.session'); var viewRegistry = require('web.view_registry'); var _t = core._t; @@ -253,7 +254,9 @@ FormRenderer.include({ // the action does not exist anymore return $.when(); } - var rawContext = new Context(params.context, action.context); + // tz and lang are saved in the custom view + // override the language to take the current one + var rawContext = new Context(params.context, action.context, {lang: session.user_context.lang}); var context = pyUtils.eval('context', rawContext); var domain = params.domain || pyUtils.eval('domain', action.domain || '[]', action.context); var viewType = params.viewType || action.views[0][1]; diff --git a/addons/board/static/tests/dashboard_tests.js b/addons/board/static/tests/dashboard_tests.js index 08a22237a93..939fb7e721d 100644 --- a/addons/board/static/tests/dashboard_tests.js +++ b/addons/board/static/tests/dashboard_tests.js @@ -595,4 +595,49 @@ QUnit.test('subviews are aware of attach in or detach from the DOM', function (a form.destroy(); }); +QUnit.test("Views should be loaded in the user's language", function (assert) { + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'board', + data: this.data, + session: {user_context: {lang: 'fr_FR'}}, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '
', + mockRPC: function (route, args) { + if (route === "/web/dataset/search_read") { + assert.deepEqual(args.context, {lang: 'fr_FR'}, + 'The data should be loaded with the correct context'); + } + + if (route === '/web/action/load') { + return $.when({ + res_model: 'partner', + views: [[4, 'list']], + }); + } + return this._super.apply(this, arguments); + }, + archs: { + 'partner,4,list': + '', + }, + + interceptsPropagate: { + load_views: function (ev) { + assert.deepEqual(ev.data.context.eval(), {lang: 'fr_FR'}, + 'The views should be loaded with the correct context'); + } + }, + }); + + form.destroy(); +}); + }); diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js index fc26aa80713..3db879ce957 100644 --- a/addons/web/static/tests/helpers/test_utils.js +++ b/addons/web/static/tests/helpers/test_utils.js @@ -171,6 +171,12 @@ function createAsyncView(params) { }); } + if (params.interceptsPropagate) { + _.each(params.interceptsPropagate, function (cb, name) { + intercept(widget, name, cb, true); + }); + } + return view.getController(widget).then(function (view) { // override the view's 'destroy' so that it calls 'destroy' on the widget // instead, as the widget is the parent of the view and the mockServer.