[IMP] resource,web : modifies the timezone_mismatch widget
This modifies the widget to allow a title option. Task-2352428 Closes #67021 Related: odoo/upgrade#2223 Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
This commit is contained in:
committed by
Xavier BOL (xbo)
parent
96ff372034
commit
a8e6b57fef
@@ -210,6 +210,7 @@ class ResourceCalendar(models.Model):
|
||||
_tz_get, string='Timezone', required=True,
|
||||
default=lambda self: self._context.get('tz') or self.env.user.tz or 'UTC',
|
||||
help="This field is used in order to define in which timezone the resources will work.")
|
||||
tz_offset = fields.Char(compute='_compute_tz_offset', string='Timezone offset', invisible=True)
|
||||
two_weeks_calendar = fields.Boolean(string="Calendar in 2 weeks mode")
|
||||
two_weeks_explanation = fields.Char('Explanation', compute="_compute_two_weeks_explanation")
|
||||
|
||||
@@ -233,6 +234,11 @@ class ResourceCalendar(models.Model):
|
||||
(0, 0, leave._copy_leave_vals()) for leave in calendar.company_id.resource_calendar_id.global_leave_ids]
|
||||
})
|
||||
|
||||
@api.depends('tz')
|
||||
def _compute_tz_offset(self):
|
||||
for calendar in self:
|
||||
calendar.tz_offset = datetime.now(timezone(calendar.tz or 'GMT')).strftime('%z')
|
||||
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -277,7 +277,8 @@
|
||||
<field name="active" invisible="1"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="hours_per_day" widget="float_time"/>
|
||||
<field name="tz"/>
|
||||
<field name="tz" widget="timezone_mismatch" options="{'tz_offset_field': 'tz_offset', 'mismatch_title': 'Timezone Mismatch : This timezone is different from that of your browser.\nPlease, be mindful of this when setting the working hours or the time off.'}" />
|
||||
<field name="tz_offset" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
|
||||
@@ -93,7 +93,12 @@ var FieldTimezoneMismatch = FieldSelection.extend({
|
||||
|
||||
if (this.mismatch){
|
||||
$span.insertAfter(this.$el);
|
||||
$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."));
|
||||
if (this.nodeOptions.mismatch_title) {
|
||||
$span.attr('title', this.nodeOptions.mismatch_title);
|
||||
}
|
||||
else {
|
||||
$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 () {
|
||||
|
||||
Reference in New Issue
Block a user