Support dynamic default time from another field

This commit is contained in:
Akim Juillerat
2024-07-16 21:03:12 +02:00
parent 65bdd44cf8
commit 3af6b1d7f4
7 changed files with 548 additions and 10 deletions

View File

@@ -1,5 +1,21 @@
You can define the default time as follows :
You can define the default time as follows for a static value:
.. code-block:: xml
```xml
<field name="your_datetime_field" options="{'defaultTime': {'hour': 8, 'minute': 30, 'second': 15 }}"/>
```
<field name="your_datetime_field" options="{'datepicker': {'defaultTime': {'hour': , 'minute': 30, 'second': 15 }}}"/>
Otherwise you can also use a JSON field to make it dynamic through a compute function,
and reference this field in the view:
```python
start_time = field.Json(compute="_compute_start_time")
def _compute_start_time(self):
for rec in self:
rec.start_time = {'hour': 8, 'minute': 30, 'second': 15 }
```
```xml
<field name="start_time" invisible="1" />
<field name="your_datetime_field" options="{'defaultTime': 'start_time'}"/>
```