Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
1975 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor

works perfectly. thank you so much!

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
dub 23
3234
1
pro 21
3058
1
dub 25
4197
1
čvc 24
2527
3
bře 24
1720