[IMP] web: datetime new format and numeric attribute

closes odoo/documentation#14179

Related: odoo/odoo#218387
Related: odoo/enterprise#89968
Related: odoo/upgrade#8043
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Bastien PIERRE
2025-07-28 11:25:03 +02:00
parent 1dfce01d8c
commit fa241f6994
2 changed files with 34 additions and 10 deletions

View File

@@ -550,13 +550,17 @@ widget set, some specific properties are available:
:guilabel:`Decade`. If no value is selected, the user can navigate the date selector by decade.
- :guilabel:`Warning for future dates`: Enable this property to display a warning icon if a future
date is selected.
- :guilabel:`Condensed display`: Enable this property to show days, months and hours with no leading
zeros, e.g., `4/2/2025 8:05:00` instead of `04/02/2025 08:05:00`.
- :guilabel:`Date format`: By default the date will be shown as `Apr 2, 2025, 08:05 AM`.
Enable this property to show the date in the format `4/2/2025 08:05:00`.
The numeric mode is the format set on the current language. In this mode the seconds are always
shown.
- :guilabel:`Show date`: This property is enabled by default for :guilabel:`Date & Time` fields.
Disable this property to show only the time.
- :guilabel:`Show time`: This property is enabled by default for :guilabel:`Date & Time` fields. On
a read-only field, disable the property to show only the date. This can keep a list view less
cluttered, for example.
- :guilabel:`Show seconds`: This property is enabled by default for :guilabel:`Date & Time` fields.
Disable the property to show only hours and minutes.
- :guilabel:`Show seconds`: This property is disabled by default for :guilabel:`Date & Time` fields.
Enable the property to show the seconds.
- :guilabel:`Time interval`: Enter a value to determine the minute intervals shown in the time
selector. For example, enter 15 to allow quarter-hour intervals. The default value is set to 5
minutes.

View File

@@ -667,6 +667,9 @@ Char (`char`)
Date (`date`)
This is the default field type for fields of type `date`. It consists of a text
box and a date picker.
The field will show the date in a readable format like this: `Dec 19, 1997`.
The year will be hidden if it's the current one. When editing the field, the numeric format
will be shown. This format corresponds to the one set in the current language.
- Supported field types: `date`
@@ -680,17 +683,26 @@ Date (`date`)
<field name="datefield" options="{'min_date': 'today', 'max_date': '2023-12-31'}" />
- warn_future: displays a warning if the value is in the future (based on today).
- `warn_future`: displays a warning if the value is in the future (based on today).
.. code-block:: xml
<field name="datefield" options="{'warn_future': true}" />
- `numeric`: when set to true, it shows the date in the format set on the current language.
(default: `false`).
.. code-block:: xml
<field name="datefield" options="{'numeric': true}" />
.. _reference/javascript_reference/datetime_field:
Date & Time (`datetime`)
This is the default field type for fields of type `datetime`. The values are always
in the client's timezone.
in the client's timezone. The displayed format has the same behaviour as the date
field, see :ref:`Date Field <reference/javascript_reference/date_field>` description.
The readable format looks like this: `Dec 19, 1997, 10:45 AM`.
- Supported field types: `datetime`
@@ -706,13 +718,13 @@ Date & Time (`datetime`)
<field name="datetimefield" options="{'rounding': 10}" />
- `show_seconds`: when set to false, it hides the seconds from the datetime field.
The field will still accept datetime values, but the seconds will be hidden in
the UI (default: `true`).
- `show_seconds`: when set to true, it shows the seconds from the datetime field.
The field will still accept datetime values, but the seconds will be shown in
the UI (default: `false`).
.. code-block:: xml
<field name="datetimefield" widget="datetime" options="{'show_seconds': false}" />
<field name="datetimefield" widget="datetime" options="{'show_seconds': true}" />
- `show_time`: when set to false, it hides the time part from the datetime field.
The field will still accept datetime values, but the time part will be hidden in
@@ -722,6 +734,14 @@ Date & Time (`datetime`)
<field name="datetimefield" widget="datetime" options="{'show_time': false}" />
- `show_date`: when set to false, it hides the date part from the datetime field.
The field will still accept datetime values, but the date part will be hidden in
the UI (default: `true`).
.. code-block:: xml
<field name="datetimefield" widget="datetime" options="{'show_date': false}" />
Date Range (`daterange`)
This widget allows the user to select start and end date from a single picker.