From 340baef44a66a90b70688e62303ec6f2b85f3d61 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 26 Apr 2017 16:12:25 +0200 Subject: [PATCH] [FIX] web: FieldTimezoneMismatch does not work The FieldTimezoneMismatch was redone, but an error was done after the last code review. With this commit, we fix the mistake (a function is properly called) and improve the test to make sure we catch such a regression later. --- addons/web/static/src/js/fields/special_fields.js | 2 +- addons/web/static/tests/fields/special_fields.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/fields/special_fields.js b/addons/web/static/src/js/fields/special_fields.js index 50f5e293eb7..7f4c7378882 100644 --- a/addons/web/static/src/js/fields/special_fields.js +++ b/addons/web/static/src/js/fields/special_fields.js @@ -41,7 +41,7 @@ var FieldTimezoneMismatch = FieldSelection.extend({ */ _render: function () { this._super.apply(this, arguments); - this._renderTimezoneMismatch.bind(this); + this._renderTimezoneMismatch(); }, /** * Display the time in the user timezone (reload each second) diff --git a/addons/web/static/tests/fields/special_fields.js b/addons/web/static/tests/fields/special_fields.js index 3b16d0a0a62..af725a007f1 100644 --- a/addons/web/static/tests/fields/special_fields.js +++ b/addons/web/static/tests/fields/special_fields.js @@ -141,17 +141,25 @@ QUnit.module('special_fields', { QUnit.module('FieldTimezoneMismatch'); QUnit.test('widget timezone_mismatch in a list view', function (assert) { - assert.expect(3); + assert.expect(5); + this.data.partner.fields.tz_offset = {string: "tz_offset", type: "integer"}; this.data.partner.records.forEach(function (r) { r.color = 'red'; + r.tz_offset = 0; }); + this.data.partner.onchanges = { + color: function (r) { + r.tz_offset = '+4800'; // make sur we have a mismatch + } + }; var list = createView({ View: ListView, model: 'partner', data: this.data, arch: '' + + '' + '' + '', }); @@ -164,6 +172,11 @@ QUnit.module('special_fields', { assert.strictEqual($td.find('select').length, 1, "td should have a child 'select'"); assert.strictEqual($td.contents().length, 1, "select tag should be only child of td"); + + $td.find('select').val('"black"').trigger('change'); + + assert.strictEqual($td.find('.o_tz_warning').length, 1, "Should display icon alert"); + assert.ok($td.find('select option:selected').text().match(/Black\s+\([0-9]+\/[0-9]+\/[0-9]+ [0-9]+:[0-9]+:[0-9]+\)/), "Should display the datetime in the selected timezone"); list.destroy(); });