From a219bdb85e9078f88bb5a7b43b3598762a7bd819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Mon, 22 Oct 2018 12:32:51 +0000 Subject: [FIX] web: consider correct viewtype when loading data Before this commit, when loading the data and calling the prostprocess, the viewType was not correctly passed which could lead to broken behaviour. For example, if one was to load a record from a list view embedded in a form view, the viewtype passed was the list which prevented to load the data from the form view. OPW 1891295 closes odoo/odoo#28279 --- .../static/tests/fields/relational_fields_tests.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 49b868c6edb..8d6bd80d56b 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -380,6 +380,49 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('show_address works in a view embedded in a view of another type', function (assert) { + assert.expect(1); + + this.data.turtle.records[1].turtle_trululu = 2; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '', + res_id: 1, + archs: { + "turtle,false,form": '
' + + '' + + '' + + '', + "turtle,false,list": '' + + '' + + '', + }, + mockRPC: function (route, args) { + if (args.method === 'name_get') { + return this._super(route, args).then(function (result) { + if (args.model === 'partner' && args.kwargs.context.show_address) { + result[0][1] += '\nrue morgue\nparis 75013'; + } + return result; + }); + } + return this._super(route, args); + }, + }); + // click the turtle field, opens a modal with the turtle form view + form.$('.o_data_row:first td.o_data_cell').click(); + + assert.strictEqual($('[name="turtle_trululu"]').text(), "second recordrue morgueparis 75013", + "The partner's address should be displayed"); + form.destroy(); + }); + QUnit.test('many2ones in form views with search more', function (assert) { assert.expect(3); this.data.partner.records.push({ -- cgit v1.2.3 From 180f5285286c6bf4753935680fb493d4b5e04a36 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Tue, 30 Oct 2018 10:16:09 +0000 Subject: [FIX] web: reload many2one data if the context has changed When a view is loaded, it checks which fields it has to load. In the case of a many2one, it could be the case that a context key is present in one view and not in the other; if it happens, we should reload the data, as a name_get result could vary. opw 1891295 closes odoo/odoo#28298 --- .../static/tests/fields/relational_fields_tests.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 8d6bd80d56b..fda7c1b7394 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -423,6 +423,50 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('many2one data is reloaded if there is a context to take into account', function (assert) { + assert.expect(1); + + this.data.turtle.records[1].turtle_trululu = 2; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '', + res_id: 1, + archs: { + "turtle,false,form": '
' + + '' + + '' + + '', + "turtle,false,list": '' + + '' + + '' + + '', + }, + mockRPC: function (route, args) { + if (args.method === 'name_get') { + return this._super(route, args).then(function (result) { + if (args.model === 'partner' && args.kwargs.context.show_address) { + result[0][1] += '\nrue morgue\nparis 75013'; + } + return result; + }); + } + return this._super(route, args); + }, + }); + // click the turtle field, opens a modal with the turtle form view + form.$('.o_data_row:first').click(); + + assert.strictEqual($('.modal [name=turtle_trululu]').text(), "second recordrue morgueparis 75013", + "The partner's address should be displayed"); + form.destroy(); + }); + QUnit.test('many2ones in form views with search more', function (assert) { assert.expect(3); this.data.partner.records.push({ -- cgit v1.2.3