Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
2771 Näkymät

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
Hylkää
Paras vastaus

Hi,

Update 'res_model_id',

'res_model_id': activity.res_model_id.id,

Hope it helps,
Kiran K

Avatar
Hylkää
Tekijä

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

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

please help.

regards

Tekijä

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.

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
elok. 23
2058
1
marrask. 23
3050
3
lokak. 23
2162
1
elok. 23
1964
2
kesäk. 24
5382