summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/special_fields.js
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-10-24 13:35:52 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2018-10-29 08:36:33 +0000
commiteaedfe40747dbc6c840a02a2c07db7257196eb45 (patch)
treeb2eb1c3e0edea8293f7b703eb00d441ef8dabd3b /addons/web/static/tests/fields/special_fields.js
parente6bb3eb3e00b788a06b1757c8df534514267e5cb (diff)
[FIX] web: display of timezone mismatch select widget
On the user's preference, change the timezone to one that is different from the browser. Save the form. Go back to the user's preferences. Before this commit, every timezone was displayed inside the span that contain the warning icon, and leaked everywhere on the form view. This was because of the joint action effects of commits: 86897ca167338ca434e62827fa09f44ddbce324c 4dfabb8f7adde06a7936502af61534c9958ed4f7 Which provoked the field to be re-rendered in edit mode, but with an $el on which a span was added. `<option/>` elements were then added to both `<select>` and `<span>` This did not happen before v12.0 After this commit, there is no display glitch OPW 1895088 closes odoo/odoo#28108
Diffstat (limited to 'addons/web/static/tests/fields/special_fields.js')
-rw-r--r--addons/web/static/tests/fields/special_fields.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/special_fields.js b/addons/web/static/tests/fields/special_fields.js
index 3592f813fae..8a605458546 100644
--- a/addons/web/static/tests/fields/special_fields.js
+++ b/addons/web/static/tests/fields/special_fields.js
@@ -213,6 +213,48 @@ QUnit.module('special_fields', {
form.destroy();
});
+ QUnit.test('widget timezone_mismatch in a form view edit mode with mismatch', function (assert) {
+ assert.expect(3);
+
+ this.data.partner.fields.tz_offset = {
+ string: "tz_offset",
+ type: "char"
+ };
+ this.data.partner.fields.tz = {
+ type: "selection",
+ selection: [['Europe/Brussels', "Europe/Brussels"], ['America/Los_Angeles', "America/Los_Angeles"]],
+ };
+ this.data.partner.records[0].tz = 'America/Los_Angeles';
+ this.data.partner.records[0].tz_offset = '+4800';
+
+ var form = createView({
+ debug:true,
+ View: FormView,
+ model: 'partner',
+ res_id: 1,
+ data: this.data,
+ arch: '<form>' +
+ '<field name="tz_offset" invisible="True"/>' +
+ '<field name="tz" widget="timezone_mismatch" options="{\'tz_offset_field\': \'tz_offset\'}"/>' +
+ '</form>',
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ var $timezoneEl = form.$('select[name="tz"]');
+ assert.strictEqual($timezoneEl.children().length, 3,
+ 'The select element should have 3 children');
+
+ var $timezoneMismatch = form.$('.o_tz_warning');
+ assert.strictEqual($timezoneMismatch.length, 1,
+ 'timezone mismatch is present');
+
+ assert.notOk($timezoneMismatch.children().length,
+ 'The mismatch element should not have children');
+ form.destroy();
+ });
+
QUnit.module('FieldReportLayout');
QUnit.test('report_layout widget in form view', function (assert) {