Skip to content

Commit fa241f6

Browse files
committed
[IMP] web: datetime new format and numeric attribute
closes #14179 Related: odoo/odoo#218387 Related: odoo/enterprise#89968 Related: odoo/upgrade#8043 Signed-off-by: Antoine Vandevenne (anv) <[email protected]>
1 parent 1dfce01 commit fa241f6

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

content/applications/studio/fields.rst

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

content/developer/reference/frontend/javascript_reference.rst

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ Char (`char`)
667667
Date (`date`)
668668
This is the default field type for fields of type `date`. It consists of a text
669669
box and a date picker.
670+
The field will show the date in a readable format like this: `Dec 19, 1997`.
671+
The year will be hidden if it's the current one. When editing the field, the numeric format
672+
will be shown. This format corresponds to the one set in the current language.
670673

671674
- Supported field types: `date`
672675

@@ -680,17 +683,26 @@ Date (`date`)
680683
681684
<field name="datefield" options="{'min_date': 'today', 'max_date': '2023-12-31'}" />
682685
683-
- warn_future: displays a warning if the value is in the future (based on today).
686+
- `warn_future`: displays a warning if the value is in the future (based on today).
684687

685688
.. code-block:: xml
686689
687690
<field name="datefield" options="{'warn_future': true}" />
688691
692+
- `numeric`: when set to true, it shows the date in the format set on the current language.
693+
(default: `false`).
694+
695+
.. code-block:: xml
696+
697+
<field name="datefield" options="{'numeric': true}" />
698+
689699
.. _reference/javascript_reference/datetime_field:
690700

691701
Date & Time (`datetime`)
692702
This is the default field type for fields of type `datetime`. The values are always
693-
in the client's timezone.
703+
in the client's timezone. The displayed format has the same behaviour as the date
704+
field, see :ref:`Date Field <reference/javascript_reference/date_field>` description.
705+
The readable format looks like this: `Dec 19, 1997, 10:45 AM`.
694706

695707
- Supported field types: `datetime`
696708

@@ -706,13 +718,13 @@ Date & Time (`datetime`)
706718
707719
<field name="datetimefield" options="{'rounding': 10}" />
708720
709-
- `show_seconds`: when set to false, it hides the seconds from the datetime field.
710-
The field will still accept datetime values, but the seconds will be hidden in
711-
the UI (default: `true`).
721+
- `show_seconds`: when set to true, it shows the seconds from the datetime field.
722+
The field will still accept datetime values, but the seconds will be shown in
723+
the UI (default: `false`).
712724

713725
.. code-block:: xml
714726
715-
<field name="datetimefield" widget="datetime" options="{'show_seconds': false}" />
727+
<field name="datetimefield" widget="datetime" options="{'show_seconds': true}" />
716728
717729
- `show_time`: when set to false, it hides the time part from the datetime field.
718730
The field will still accept datetime values, but the time part will be hidden in
@@ -722,6 +734,14 @@ Date & Time (`datetime`)
722734
723735
<field name="datetimefield" widget="datetime" options="{'show_time': false}" />
724736
737+
- `show_date`: when set to false, it hides the date part from the datetime field.
738+
The field will still accept datetime values, but the date part will be hidden in
739+
the UI (default: `true`).
740+
741+
.. code-block:: xml
742+
743+
<field name="datetimefield" widget="datetime" options="{'show_date': false}" />
744+
725745
Date Range (`daterange`)
726746
This widget allows the user to select start and end date from a single picker.
727747

0 commit comments

Comments
 (0)