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

trying to create new/next activity through automated action - execute python code. please check the code below, when this code executes, its throwing error 


ValueError: [class 'psycopg2.ProgrammingError']: "can't adapt type 'ir.model'" while evaluating


the python code in automated action on update of mail.activity which should execute on Save button: 

Python Code:


activity = record


new_activity_name = "Follow-up: {} 123" 

new_activity_summary = "Follow-up on activity {} 123" 


new_mail_activity = env['mail.activity'].create({

'activity_type_id' : 2, 

'note' : "Follow-up note for activity {} 123", 

'display_name': new_activity_name,

'summary': new_activity_summary,

'user_id': activity.user_id.id,

'date_deadline': activity.date_deadline,

'res_id': activity.res_id,

'res_model_id': activity.res_model_id 

})


env['log'].create({'message': "New follow-up activity scheduled for activity {} 123"})



regards

아바타
취소
베스트 답변

Hi,

Update 'res_model_id',

'res_model_id': activity.res_model_id.id,

Hope it helps,
Kiran K

아바타
취소
작성자

thank you @Kiran for reply, now it is showing another Error as below:

ValueError: <class 'KeyError'>: "log" while evaluating

please help.

regards

작성자

when remarked last line env['log'].create({'message': ... it is creating activity successfully... what wrong with that last line?

In the final line, you are trying to create a record in the 'log' model.
The error occurs because there is no existing model named 'log' in your instance.

관련 게시물 답글 화면 활동
1
8월 23
2602
1
11월 23
3472
3
10월 23
2729
1
8월 23
2241
2
6월 24
6189