diff options
| author | Thibault Delavallée <tde@odoo.com> | 2020-08-03 08:34:26 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-08-03 15:10:14 +0000 |
| commit | ef9b26f06486d0201db3b9dc82b32af01a11ef0b (patch) | |
| tree | 70dde12f6d867a9ea38643e28a326388356ab4fe | |
| parent | 260383a2e27a538a34ea58e28f1f998ffef99e52 (diff) | |
[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
| -rw-r--r-- | odoo/addons/base/i18n/base.pot | 42 | ||||
| -rw-r--r-- | odoo/addons/base/models/ir_qweb_fields.py | 10 |
2 files changed, 51 insertions, 1 deletions
diff --git a/odoo/addons/base/i18n/base.pot b/odoo/addons/base/i18n/base.pot index 7ebb1f343ad..8cea48401b7 100644 --- a/odoo/addons/base/i18n/base.pot +++ b/odoo/addons/base/i18n/base.pot @@ -7193,6 +7193,18 @@ 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" msgstr "" @@ -12537,6 +12549,12 @@ 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 msgid "Format email address \"Name <email@domain>\"" @@ -15574,6 +15592,12 @@ 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" msgstr "" @@ -16809,6 +16833,12 @@ 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" msgstr "" @@ -18552,6 +18582,12 @@ 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" msgstr "" @@ -21510,6 +21546,12 @@ 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" msgstr "" diff --git a/odoo/addons/base/models/ir_qweb_fields.py b/odoo/addons/base/models/ir_qweb_fields.py index da6d9f86390..28591cb917c 100644 --- a/odoo/addons/base/models/ir_qweb_fields.py +++ b/odoo/addons/base/models/ir_qweb_fields.py @@ -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): |
