Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3207 Представления

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.

Related Posts Ответы Просмотры Активность
1
авг. 23
2483
1
нояб. 23
3384
3
окт. 23
2595
1
авг. 23
2196
2
июн. 24
5980