summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorPratima Gupta <pgu@odoo.com>2017-08-17 12:29:21 +0530
committerAaron Bohy <aab@odoo.com>2017-09-19 10:14:24 +0200
commitde48daf53adc922da6b2ff4ef794e37b0b7cd835 (patch)
tree70f6c18e86975e5b1feb04b2df56493b17c68413 /addons/web
parent116aa22685c8aa3babd87c8d1091a53fbf4ff35b (diff)
[FIX] web: FieldDomain: don't open record from selection
The FieldDomain allows to open a list in a dialog to display the records matching the current domain. In this dialog, clicking on a record should do nothing (this was the behavior before the new views). Before this rev., it actually tried to open the record and it produced a crash.
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js14
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js40
2 files changed, 52 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index d9482156745..2a465c4dc1b 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -1994,8 +1994,9 @@ var FieldDomain = AbstractField.extend({
"click .o_field_domain_dialog_button": "_onDialogEditButtonClick",
}),
custom_events: _.extend({}, AbstractField.prototype.custom_events, {
- "domain_changed": "_onDomainSelectorValueChange",
- "domain_selected": "_onDomainSelectorDialogValueChange",
+ domain_changed: "_onDomainSelectorValueChange",
+ domain_selected: "_onDomainSelectorDialogValueChange",
+ open_record: "_onOpenRecord",
}),
/**
* @constructor
@@ -2176,6 +2177,15 @@ var FieldDomain = AbstractField.extend({
_onDomainSelectorDialogValueChange: function (e) {
this._setValue(Domain.prototype.arrayToString(e.data.domain));
},
+ /**
+ * Stops the propagation of the 'open_record' event, as we don't want the
+ * user to be able to open records from the list opened in a dialog.
+ *
+ * @param {OdooEvent} event
+ */
+ _onOpenRecord: function (event) {
+ event.stopPropagation();
+ },
});
/**
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index c33cb8a4151..90f2b14cb01 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -3795,6 +3795,46 @@ QUnit.module('basic_fields', {
form.destroy();
});
+
+ QUnit.test('basic domain field: show the selection', function (assert) {
+ assert.expect(2);
+
+ this.data.partner.records[0].foo = "[]";
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:
+ '<form>' +
+ '<sheet>' +
+ '<group>' +
+ '<field name="foo" widget="domain" options="{\'model\': \'partner_type\'}"/>' +
+ '</group>' +
+ '</sheet>' +
+ '</form>',
+ archs: {
+ 'partner_type,false,list': '<tree><field name="display_name"/></tree>',
+ 'partner_type,false,search': '<search><field name="name" string="Name"/></search>',
+ },
+ res_id: 1,
+ });
+
+ assert.equal(form.$(".o_domain_show_selection_button").text().trim().substr(0, 2), "2 ",
+ "selection should contain 2 records");
+
+ // open the selection
+ form.$(".o_domain_show_selection_button").click();
+ assert.strictEqual($('.modal .o_list_view .o_data_row').length, 2,
+ "should have open a list view with 2 records in a dialog");
+
+ // click on a record -> should not open the record
+ // we don't actually check that it doesn't open the record because even
+ // if it tries to, it will crash as we don't define an arch in this test
+ $('.modal .o_list_view .o_data_row:first .o_data_cell').click();
+
+ form.destroy();
+ });
});
});
});