From 6158c5ce04589d7e51928d2d19aa5b2eec05cebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 15 Nov 2017 11:45:26 +0100 Subject: [FIX] web: fix issue with combination of o2m, m2m, and m2o Consider this: a form view with a one2many list view. In the one2many list view, there is a many2one field. When opening the manyone in a modal form view, there is a many2many field. In that situation, clicking on 'Add a new record' on the many2many field had the unfortunate effect of interfering with the one2many field in the main form view, which caused a crash or the modal form view to close unexpectedly. The issue is that an event was simply not properly stopped at the proper location. This is usually not a big deal, but, as described above, it can be a problem in some cases. --- .../static/tests/fields/relational_fields_tests.js | 59 ++++++++++++++++++++++ 1 file changed, 59 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 8a67f6eec05..4c78c2ec550 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -5158,6 +5158,65 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('many2many list in a one2many opened by a many2one', 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: { + "partner,false,form": '
' + + '' + + '', + "partner_type,false,list": '' + + '' + + '', + "partner_type,false,search": '' + + '', + }, + viewOptions: { + mode: 'edit', + }, + mockRPC: function (route, args) { + if (route === '/web/dataset/call_kw/partner/get_formview_id') { + return $.when(false); + } + if (args.method === 'write') { + assert.deepEqual(args.args[1].timmy, [[6, false, [12]]], + 'should properly write ids') + } + return this._super.apply(this, arguments); + }, + }); + + // edit the first partner in the one2many partner form view + form.$('.o_data_row:first td.o_data_cell').click(); + // open form view for many2one + form.$('.o_external_button').click(); + + // click on add, to add a new partner in the m2m + $('.modal .o_field_x2many_list_row_add a').click(); + + // select the partner_type 'gold' (this closes the 2nd modal) + $('.modal td:contains(gold)').click(); + + // confirm the changes in the modal + $('.modal .modal-footer .btn-primary').click(); + + form.$buttons.find('.o_form_button_save').click(); + form.destroy(); + }); + QUnit.test('one2many (who contains display_name) with tree view and without form view', function (assert) { assert.expect(1); -- cgit v1.2.3