summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-11-15 11:45:26 +0100
committerGéry Debongnie <ged@odoo.com>2017-11-15 13:48:49 +0100
commit6158c5ce04589d7e51928d2d19aa5b2eec05cebf (patch)
tree5e823c95e32ac0054e93577468439fd1249b240a /addons/web
parent6d616c566f8fbd49d277720c04abd079a04ced76 (diff)
[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.
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js6
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js59
2 files changed, 64 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index c9e6f218895..e7cd2e1eebf 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -1191,9 +1191,13 @@ var FieldMany2Many = FieldX2Many.extend({
*
* @override
* @private
+ * @param {OdooEvent|MouseEvent} ev this event comes either from the 'Add
+ * record' link in the list editable renderer, or from the 'Create' button
+ * in the kanban view
*/
- _onAddRecord: function () {
+ _onAddRecord: function (ev) {
var self = this;
+ ev.stopPropagation();
var domain = this.record.getDomain({fieldName: this.name});
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: '<form string="Partners">' +
+ '<field name="turtles">' +
+ '<tree editable="bottom">' +
+ '<field name="turtle_trululu"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ archs: {
+ "partner,false,form": '<form string="P">' +
+ '<field name="timmy"/>' +
+ '</form>',
+ "partner_type,false,list": '<tree editable="bottom">' +
+ '<field name="display_name"/>' +
+ '</tree>',
+ "partner_type,false,search": '<search>' +
+ '</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);