Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
3131 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

Hi,

Update 'res_model_id',

'res_model_id': activity.res_model_id.id,

Hope it helps,
Kiran K

Avatar
Zrušit
Autor

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

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

please help.

regards

Autor

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 Odpovědi Zobrazení Aktivita
1
srp 23
2410
1
lis 23
3296
3
říj 23
2493
1
srp 23
2128
2
čvn 24
5829