Skip to content

Commit

Permalink
[FIX] web: FieldTimezoneMismatch does not work
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gorash authored and ged-odoo committed Apr 28, 2017
1 parent e7a1187 commit 340baef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/web/static/src/js/fields/special_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion addons/web/static/tests/fields/special_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<tree string="Colors" editable="top">' +
'<field name="tz_offset" invisible="True"/>' +
'<field name="color" widget="timezone_mismatch"/>' +
'</tree>',
});
Expand All @@ -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();
});

Expand Down

0 comments on commit 340baef

Please sign in to comment.