跳至內容
選單
此問題已被標幟
2 回覆
1475 瀏覽次數

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.

頭像
捨棄
作者 最佳答案

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

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
2月 20
5198
1
10月 23
1373
0
11月 22
2279
0
7月 20
2438
0
5月 20
6197