Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar

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

Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 22
3383
1
nov 23
1589
0
nov 23
965
2
dic 23
5217
1
mar 23
8119