تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2055 أدوات العرض

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!

الصورة الرمزية
إهمال

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 22
3760
1
نوفمبر 23
2081
0
نوفمبر 23
1200
2
ديسمبر 23
5652
1
مارس 23
9123