[IMP] base: support giving tzinfo to QWeb babel datetime format
PURPOSE Allow to finely tune display of datetimes in front-end by adding support of tzinfo parameter of babel format_datetime. See babel for more details about its use. Also add some missing translations bits due to last QWeb options added. LINKS Followup of 69d2513de21c2e80de605f77912a3687b8a79c6d PR #55325 X-original-commit: c7d6e90c93e505950496eec382c89a9936d243be
This commit is contained in:
@@ -7192,6 +7192,18 @@ msgstr ""
|
||||
msgid "Add delivery costs to online sales"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid "Add direction"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid "Add directional information (not used for digital)"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: model:ir.module.module,summary:base.module_base_address_extended
|
||||
msgid "Add extra fields on addresses"
|
||||
@@ -12536,6 +12548,12 @@ msgstr ""
|
||||
msgid "Form"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid "Format"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: model:ir.model.fields,help:base.field_res_partner__email_formatted
|
||||
#: model:ir.model.fields,help:base.field_res_users__email_formatted
|
||||
@@ -15573,6 +15591,12 @@ msgstr ""
|
||||
msgid "Logs"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid "Long"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: model:ir.module.module,shortdesc:base.module_pos_loyalty
|
||||
msgid "Loyalty Program"
|
||||
@@ -16808,6 +16832,12 @@ msgstr ""
|
||||
msgid "Namibia"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid "Narrow"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: model:res.country,name:base.nr
|
||||
msgid "Nauru"
|
||||
@@ -18551,6 +18581,12 @@ msgstr ""
|
||||
msgid "Optional password for SMTP authentication"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid "Optional timezone name"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: model:ir.model.fields,help:base.field_ir_mail_server__smtp_user
|
||||
msgid "Optional username for SMTP authentication"
|
||||
@@ -21509,6 +21545,12 @@ msgstr ""
|
||||
msgid "Shopper's Wishlist"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid "Short"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: model:ir.model.fields,field_description:base.field_base_module_uninstall__show_all
|
||||
msgid "Show All"
|
||||
|
||||
@@ -222,6 +222,7 @@ class DateTimeConverter(models.AbstractModel):
|
||||
options = super(DateTimeConverter, self).get_available_options()
|
||||
options.update(
|
||||
format=dict(type='string', string=_('Pattern to format')),
|
||||
tz_name=dict(type='char', string=_('Optional timezone name')),
|
||||
time_only=dict(type='boolean', string=_('Display only the time')),
|
||||
hide_seconds=dict(type='boolean', string=_('Hide seconds')),
|
||||
date_only=dict(type='boolean', string=_('Display only the date')),
|
||||
@@ -242,6 +243,11 @@ class DateTimeConverter(models.AbstractModel):
|
||||
|
||||
value = fields.Datetime.context_timestamp(self, value)
|
||||
|
||||
if options.get('tz_name'):
|
||||
tzinfo = babel.dates.get_timezone(options['tz_name'])
|
||||
else:
|
||||
tzinfo = None
|
||||
|
||||
if 'format' in options:
|
||||
pattern = options['format']
|
||||
else:
|
||||
@@ -259,10 +265,12 @@ class DateTimeConverter(models.AbstractModel):
|
||||
|
||||
if options.get('time_only'):
|
||||
format_func = babel.dates.format_time
|
||||
return pycompat.to_text(format_func(value, format=pattern, locale=locale))
|
||||
if options.get('date_only'):
|
||||
format_func = babel.dates.format_date
|
||||
return pycompat.to_text(format_func(value, format=pattern, locale=locale))
|
||||
|
||||
return pycompat.to_text(format_func(value, format=pattern, locale=locale))
|
||||
return pycompat.to_text(format_func(value, format=pattern, tzinfo=tzinfo, locale=locale))
|
||||
|
||||
|
||||
class TextConverter(models.AbstractModel):
|
||||
|
||||
Reference in New Issue
Block a user