Skip to Content
Menu
This question has been flagged

Hi,

I am using Odoo SaaS Enterprise V15

I have three custom date fields in the same form.

If one of the date fields is changed, then I want the other two to update relative to it based on lead times.

E.g. If dateB is changed, then dateA = dateB - 1 and dateC = dateB + 1 (just an example of the logic.

I have created some automated actions that do the above correctly, but only on existing records. When I try to create a new record (production order), I get the " RPC_ERROR

Odoo Server Error".

I suspect this is because the date fields are null upon creation so the below computations give an error.

How can I prevent the error so I can use this automated action?


Here is the automated action (using example fields):

Trigger: Based on Form Modification

Trigger Fields: date_b, date_b_lead_time

Action to do: Execute Python Code

Python Code:

record['x_studio_date_a'] = record.x_studio_date_b - datetime.timedelta(days=record.x_studio_date_a_lead_time)
record['x_studio_date_c'] = record.x_studio_date_b + datetime.timedelta(days=record.x_studio_date_c_lead_time)

Thanks in advance!

Avatar
Discard

add if conditions and ensure that the field contains value in it

Related Posts Replies Views Activity
1
Sep 22
2542
1
Nov 23
870
0
Nov 23
450
2
Dec 23
4064
1
Mar 23
6240