Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1916 Vistas

Hi,

I am working with Odoo Web Enterprise 17.0+e.

As shown in the image below, I have 2 fields with type of Date: Last Inspect and Next Inspect. Currently I input those manually and what I want to do is when I input date of Last Inspect, the date of Next Inspect will be automatically filled with date of 3 months range from the date of Last Inspect. So Next Inspect will be a read only field. I tried with automations but still fruitless.

Is this possible to achieve?

Thanks in advance!

Avatar
Descartar
Mejor respuesta

Hello zulsani

You can actually do it using the Settings => Technical => Automation => Automation Rules

you have to enable debug mode first or the menu will be hidden

1- create a new automation rule and assign it any name e.g(Set Next Inspect Date)

2- Select the model the fields exist in ( if you dont know the name of the model you can search by model technical name and i will explain it in the end of the answer how to get this technical name)

3- Set Trigger to On UI Change

4- Set when Updating to Last Inspect

5- Add action

6- select the action type Execute Code


Set the following code

record.update({
​"next_inspect_field_technical_name" : record.last_inspect_field_technical_name+dateutil.relativedelta.relativedelta(months=3)
})


You can know the next_inspect_field_technical_name and the last_inspect_field_technical_name by activating debug mode then hover by the mouse on the question mark next to the field, the field name will be written in front of Field

see the example below the field technical name is ref and the model technical name is (account.move which is journal entry)

Avatar
Descartar
Autor

works perfectly. thank you so much!

Mejor respuesta

Hello

Add the Compute method for the field Next Inspect, inside the Compute Method, Add your calculation After 3 days of Last Inspect.

In the field Advanced Properties you can add dependencies and Compute function. Here add dependency as the Last Inspect field and apply your condition.

Define Compute Method For A Field-Studio


Regards


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
4
abr 23
3185
1
dic 21
3024
1
abr 25
4145
1
jul 24
2479
3
mar 24
1686