many2many create method error: unhashable type: 'list' Odoo 17.0

56 Views Asked by At

I'm trying to import slack channels into odoo but the above mentioned error arises. I am trying to populate a many2many field. I tried to pass tuple into it but got no luck. If anyone has any suggestions,do reply. While debugging, I realized that the error occurs when the ORM methods like write or create gets triggered. Following is my line of code which I believe is the reason behind this error: 'channel_partner_ids': [(6, 0, tuple(total_partner_ids))]

1

There are 1 best solutions below

0
On

In your case total_partner_ids is already a list. And if I translate your code, it look like this

'channel_partner_ids': [(6, 0, ([1,2,3,4,...],))]

But if you look the Odoo documentation the magic number 6 work like this :

(6, 0, [IDs])          replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

To resolve your code, you must remove the tuple function called.

'channel_partner_ids': [(6, 0, total_partner_ids)]