summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-07-23 10:01:11 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-07-23 13:48:37 +0000
commit78b09d82fb16181c3ae2e4964f3cff30b76424db (patch)
tree6862214635c0ebcb2a509cd989bc6c4accd3cbee
parent860ab5a1c28ba85d7a193d68cfbbb1063bbf0651 (diff)
[FIX] web: pivot keeps controlpanel's domain on reload
Open a pivot view, make a search for some field Click on a pivot cell to display the list view of elements matching the group's domain Go back to the pivot using breadcrumbs Before this commit, the original search domain was not kept across those actions After this commit, it is kept This difference is due to the fact that before 12.2, the whole action had an env, containing the search domain in 12.2 and afterwards, things are not done this way anymore OPW 2030555 OPW 2030983 closes odoo/odoo#35096 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
-rw-r--r--addons/web/static/src/js/views/pivot/pivot_model.js1
-rw-r--r--addons/web/static/tests/views/pivot_tests.js68
2 files changed, 68 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js
index b60cf81ac86..2c41200ec0f 100644
--- a/addons/web/static/src/js/views/pivot/pivot_model.js
+++ b/addons/web/static/src/js/views/pivot/pivot_model.js
@@ -422,6 +422,7 @@ var PivotModel = AbstractModel.extend({
}
if ('domain' in params) {
this.data.domain = params.domain;
+ this.initialDomain = params.domain;
} else {
this.data.domain = this.initialDomain;
}
diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js
index 2fca169e591..ed47c253cfa 100644
--- a/addons/web/static/tests/views/pivot_tests.js
+++ b/addons/web/static/tests/views/pivot_tests.js
@@ -4,6 +4,7 @@ odoo.define('web.pivot_tests', function (require) {
var core = require('web.core');
var PivotView = require('web.PivotView');
var testUtils = require('web.test_utils');
+var testUtilsDom = require('web.test_utils_dom');
var createActionManager = testUtils.createActionManager;
var patchDate = testUtils.mock.patchDate;
@@ -16,7 +17,7 @@ QUnit.module('Views', {
this.data = {
partner: {
fields: {
- foo: {string: "Foo", type: "integer"},
+ foo: {string: "Foo", type: "integer", searchable: true},
bar: {string: "bar", type: "boolean"},
date: {string: "Date", type: "date", store: true, sortable: true},
product_id: {string: "Product", type: "many2one", relation: 'product', store: true},
@@ -1841,6 +1842,71 @@ QUnit.module('Views', {
actionManager.destroy();
});
+ QUnit.test('Navigation list view for a group and back with breadcrumbs', function (assert) {
+ assert.expect(16);
+ // create an action manager to test the interactions with the search view
+ var readGroupCount = 0;
+ var actionManager = createActionManager({
+ data: this.data,
+ archs: {
+ 'partner,false,pivot': '<pivot>' +
+ '<field name="customer" type="row"/>' +
+ '</pivot>',
+ 'partner,false,search': '<search><filter name="bayou" string="Bayou" domain="[(\'foo\',\'=\', 12)]"/></search>',
+ 'partner,false,list': '<tree><field name="foo"/></tree>',
+ 'partner,false,form': '<form><field name="foo"/></form>',
+ },
+ intercepts: {
+ do_action: function (event) {
+ var action = event.data.action;
+ actionManager.doAction(action);
+ }
+ },
+ mockRPC: function (route, args) {
+ if (args.method === 'read_group') {
+ assert.step('read_group');
+ var domain = args.kwargs.domain;
+ if ([0,1].indexOf(readGroupCount) !== -1) {
+ assert.deepEqual(domain, [], 'initial domain empty');
+ } else if ([2,3,4,5].indexOf(readGroupCount) !== -1) {
+ assert.deepEqual(domain, [['foo', '=', 12]],
+ 'domain conserved when back with breadcrumbs');
+ }
+ readGroupCount++;
+ }
+ if (route === '/web/dataset/search_read') {
+ assert.step('search_read');
+ var domain = args.domain;
+ assert.deepEqual(domain, [['foo', '=', 12], ['customer', '=', 1], ['foo', '=', 12]],
+ 'list domain is correct');
+ }
+ return this._super.apply(this, arguments);
+ }
+ });
+
+ actionManager.doAction({
+ res_model: 'partner',
+ type: 'ir.actions.act_window',
+ views: [[false, 'pivot']],
+ });
+
+ testUtilsDom.click(actionManager.$('.o_filters_menu_button'));
+ testUtilsDom.click(actionManager.$('.o_menu_item:contains("Bayou")'));
+
+ testUtilsDom.click(actionManager.$('.o_pivot_cell_value:nth(1)'))
+
+ assert.containsOnce(actionManager, '.o_list_view');
+
+ testUtilsDom.click(actionManager.$('.o_control_panel .breadcrumb-item:first() a'));
+
+ assert.verifySteps([
+ 'read_group', 'read_group',
+ 'read_group', 'read_group',
+ 'search_read',
+ 'read_group', 'read_group'])
+ actionManager.destroy();
+ });
+
QUnit.module('Sort in comparison mode', {
beforeEach: function () {
this.data.partner.records[0].date = '2016-12-15';