Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1476 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 20
5198
1
thg 10 23
1374
0
thg 11 22
2281
0
thg 7 20
2438
0
thg 5 20
6197