콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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
9월 22
3965
1
11월 23
2273
0
11월 23
1378
2
12월 23
5904
1
3월 23
9500