Skip to Content
Menu
This question has been flagged

Hi everyone,

I was trying to create "many2many" field in "res.partner" and the comodel_name  is also res.partner. but while updating the module it shows.

AssertionError: res.partner.indi_joint_members_ids: Implicit/canonical naming of many2many relationship table is not possible when source and destination models are the same

its says that for same destination and source models it is not possible

here is the code

indi_joint_members_ids = fields.Many2many('res.partner',                                       									​relation_table='res_partner_res_partner_rel',
string="Individual / Joint Members",
store=True)

But i was able to create the same field from odoo front end with "ir.model.fields"  and the source and destination model is also same "res.partner" , well I tried to add values to it and its working(No Errors)
here is the screenshot.


"Solved this issue by creating field in "ir.model.fields" while installing the module with pre_init_hook And add the x_ field to the xml"  

------------------------------------------------------------------------------------------------------

But I am not sure this is the proper method to do it. Am i doing something wrong?

can anyone suggest a proper method to do it?


Thank You.

Avatar
Discard
Author Best Answer

Hi,

found the solution.

indi_joint_members_ids = fields.Many2many('res.partner',
relation="res_partner_res_partner_rel",
column1="id1",
column2="id2",
string="Individual / Joint Members",
store=True)

the above code works

Avatar
Discard
Best Answer

Yes this is the correct way, i once had same requirement in product.product and product.template.

Avatar
Discard
Related Posts Replies Views Activity
0
Feb 20
4941
1
Oct 23
973
0
Nov 22
2035
0
Jul 20
2209
0
May 20
5782