Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
1923 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Auteur

works perfectly. thank you so much!

Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
4
apr. 23
3189
1
dec. 21
3027
1
apr. 25
4151
1
jul. 24
2486
3
mrt. 24
1690