summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-08-29 11:57:33 +0200
committerAaron Bohy <aab@odoo.com>2017-08-29 13:12:34 +0200
commitc5bf53682e159343ee0c707f6d7f2da972d6add2 (patch)
treedcb899ae0e46124afaab193f54d532e6999d8373 /addons/web/static/tests/fields/relational_fields_tests.js
parent5149e18ec704df151c03d3b1e35d5f04328b89d3 (diff)
[FIX] web: prevent 'load' event from being handled twice
In grouped list view, when a pager is clicked inside a group, a 'load' event is triggered to reload the data with the new offset. The event is handled by the list's controller. However, when the list is in the modal, the event must be stop propagated by the controller of the modal, so that it doesn't go up to the controller of the view displayed behind the modal. It happens for example by reproducing the following steps: - go to Lunch - add a line - search more products - group by vendor in the modal - unfold a group - click on the pager (the group must contain more than 80 records) Before this rev., it crashed because the controller of the form view tried to handle the event.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index 92a24066408..e211d120fe2 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -6885,6 +6885,71 @@ QUnit.module('relational_fields', {
list.destroy();
});
+ QUnit.test('search more in many2one: group and use the pager', function (assert) {
+ assert.expect(2);
+
+ this.data.partner.records.push({
+ id: 5,
+ display_name: "Partner 4",
+ }, {
+ id: 6,
+ display_name: "Partner 5",
+ }, {
+ id: 7,
+ display_name: "Partner 6",
+ }, {
+ id: 8,
+ display_name: "Partner 7",
+ }, {
+ id: 9,
+ display_name: "Partner 8",
+ }, {
+ id: 10,
+ display_name: "Partner 9",
+ });
+
+ this.data.partner.fields.datetime.searchable = true;
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<group>' +
+ '<field name="trululu"/>' +
+ '</group>' +
+ '</sheet>' +
+ '</form>',
+
+ res_id: 1,
+ archs: {
+ 'partner,false,list': '<tree limit="7"><field name="display_name"/></tree>',
+ 'partner,false,search': '<search><group>' +
+ ' <filter name="bar" string="Bar" context="{\'group_by\': \'bar\'}"/>' +
+ '</group></search>',
+ },
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ var $dropdown = form.$('.o_field_many2one input').autocomplete('widget');
+ form.$('.o_field_many2one input').click();
+ $dropdown.find('.o_m2o_dropdown_option:contains(Search)').mouseenter().click(); // Open Search More
+
+ $('.modal .o_searchview_more').click(); // Magnifying class for more filters
+ $('.modal .o_search_options .o_group_by_menu a:contains(Bar)').click(); // group by 'Bar'
+
+ $('.modal .o_group_header:first').click();
+ assert.strictEqual($('.modal tbody:nth(1) .o_data_row').length, 7,
+ "should display 7 records in the first page");
+ $('.modal .o_group_header:first .o_pager_next').click();
+ assert.strictEqual($('.modal tbody:nth(1) .o_data_row').length, 1,
+ "should display 1 record in the second page");
+
+ form.destroy();
+ });
+
QUnit.test('field many2many_tags keeps focus when being edited', function (assert) {
assert.expect(7);