summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2020-05-25 14:41:42 +0000
committerNicolas Lempereur <nle@odoo.com>2020-05-27 16:56:19 +0000
commit9d40ec7d15898ee9f3d2a92c7264690586c35cd8 (patch)
tree501e37bd8c702b9299c9595e3b77236d9e73afc6 /addons/web/static/tests/fields
parentba20e42cc3acdb16f7dffb5d15e8d9cdf9f153ce (diff)
[FIX] web: resquencing stop at first controller
When a resequencing is done inside an object hierarchy of two controllers, since 9b90d8727d we would call resquencing code one time per controller. So if for example we are in a list view inside a form view (eg. a "Search More" modal in a form view) the resequencing would work for the list view, but then cause traceback when it is handled by form view. With this changeset, the first controller that get the event `resequence_records` even gobbles it up. Without change, added test fails because of original traceback: Cannot read property 'res_id' of undefined@ 202 ms Source: TypeError: Cannot read property 'res_id' of undefined at /web/static/src/js/views/basic/basic_controller.js:744:67 ... opw-2256818 closes #51827 closes odoo/odoo#52018 X-original-commit: eef4b99fdb9469c040af80d055933eda367b7b3d Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields')
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_many2one_tests.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js b/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js
index fc95fda39d4..b43e2e102a1 100644
--- a/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js
+++ b/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js
@@ -2920,6 +2920,66 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
+ QUnit.test('search more in many2one: resequence inside dialog', async function (assert) {
+ // when the user clicks on 'Search More...' in a many2one dropdown, resequencing inside
+ // the dialog works
+ assert.expect(10);
+
+ this.data.partner.fields.sequence = { string: 'Sequence', type: 'integer' };
+ for (var i = 0; i < 8; i++) {
+ this.data.partner.records.push({id: 100 + i, display_name: 'test_' + i});
+ }
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form><field name="trululu"/></form>',
+ archs: {
+ 'partner,false,list': '<list>' +
+ '<field name="sequence" widget="handle"/>' +
+ '<field name="display_name"/>' +
+ '</list>',
+ 'partner,false,search': '<search></search>',
+ },
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ if (route === '/web/dataset/search_read') {
+ assert.deepEqual(args.domain, [],
+ "should not preselect ids as there as nothing in the m2o input");
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ await testUtils.fields.many2one.searchAndClickItem('trululu', {
+ item: 'Search More',
+ search: '',
+ });
+
+ var $modal = $('.modal');
+ assert.equal($modal.length, 1,
+ 'There should be 1 modal opened');
+
+ var $handles = $modal.find('.ui-sortable-handle');
+ assert.equal($handles.length, 11,
+ 'There should be 11 sequence handlers');
+
+ await testUtils.dom.dragAndDrop($handles.eq(1),
+ $modal.find('tbody tr').first(), { position: 'top' });
+
+ assert.verifySteps([
+ 'default_get',
+ 'name_search', // to display results in the dropdown
+ 'load_views', // list view in dialog
+ '/web/dataset/search_read', // to display results in the dialog
+ '/web/dataset/resequence', // resequencing lines
+ 'read',
+ ]);
+
+ form.destroy();
+ });
+
QUnit.test('many2one dropdown disappears on scroll', async function (assert) {
assert.expect(2);