[IMP] base : Timezone alert

- icon displayed next to field if user haven't set timezone
- added relevant tooltip
- test case added for field not set alert

Task: #1916132
Closes: #29448

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
This commit is contained in:
mgh-odoo
2019-05-31 06:58:57 +00:00
committed by Vincent Schippefilt
parent a9370e810c
commit a8f64e6e22
4 changed files with 16 additions and 8 deletions
@@ -74,6 +74,7 @@ var FieldTimezoneMismatch = FieldSelection.extend({
this.$el.last().filter('.o_tz_warning').remove();
this.$el = this.$el.first();
var value = this.$el.val();
var $span = $('<span class="fa fa-exclamation-triangle o_tz_warning"/>');
if (this.$option) {
this.$option.html(this.$option.html().split(' ')[0]);
@@ -90,15 +91,18 @@ var FieldTimezoneMismatch = FieldSelection.extend({
}
if (this.mismatch){
var $span = $('<span class="fa fa-exclamation-triangle o_tz_warning"/>');
$span.insertAfter(this.$el);
$span.attr('title', _t("Timezone Mismatch : The timezone of your browser doesn't match the selected one. The time in Odoo is displayed according to the timezone set on your user's preferences."));
$span.attr('title', _t("Timezone Mismatch : This timezone is different from that of your browser.\nPlease, set the same timezone as your browser's to avoid time discrepancies in your system."));
this.$el = this.$el.add($span);
this.$option = this.$('option').filter(function () {
return $(this).attr('value') === value;
});
this._renderDateTimeTimezone();
} else if (value == "false") {
$span.insertAfter(this.$el);
$span.attr('title', _t("Set a timezone on your user"));
this.$el = this.$el.add($span);
}
},
/**
+1 -1
View File
@@ -557,7 +557,7 @@
color: theme-color('danger');
cursor: help;
position: absolute;
margin-left: -40px;
margin-left: 10px;
margin-top: 5px;
}
@@ -185,7 +185,7 @@ QUnit.module('special_fields', {
});
QUnit.test('widget timezone_mismatch in a form view', async function (assert) {
assert.expect(1);
assert.expect(2);
this.data.partner.fields.tz_offset = {
string: "tz_offset",
@@ -210,6 +210,10 @@ QUnit.module('special_fields', {
});
await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'select[name=tz]');
var $timezoneMismatch = form.$('.o_tz_warning');
assert.strictEqual($timezoneMismatch.length, 1, "warning class should be there.");
form.destroy();
});
+4 -4
View File
@@ -155,10 +155,10 @@ class Partner(models.Model):
lang = fields.Selection(_lang_get, string='Language', default=lambda self: self.env.lang,
help="All the emails and documents sent to this contact will be translated in this language.")
tz = fields.Selection(_tz_get, string='Timezone', default=lambda self: self._context.get('tz'),
help="The partner's timezone, used to output proper date and time values "
"inside printed reports. It is important to set a value for this field. "
"You should use the same timezone that is otherwise used to pick and "
"render date and time values: your computer's timezone.")
help="When printing documents and exporting/importing data, time values are computed according to this timezone.\n"
"If the timezone is not set, UTC (Coordinated Universal Time) is used.\n"
"Anywhere else, time values are computed according to the time offset of your web client.")
tz_offset = fields.Char(compute='_compute_tz_offset', string='Timezone offset', invisible=True)
user_id = fields.Many2one('res.users', string='Salesperson',
help='The internal user in charge of this contact.')