تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
1125 أدوات العرض

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
فبراير 20
5050
1
أكتوبر 23
1158
0
نوفمبر 22
2127
0
يوليو 20
2310
0
مايو 20
5956