Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
19782 มุมมอง

Hi, I’m writing a custom module, with custom models.

One of this model inherits from res.partner, but, according to Odoo inheritance, I’m in the case « _name = my_model / _inherits = res.partner ».

If I‘m in the case _name = res.partner / inherits = res.partner : there is no problem. But as soon as I use a different _name, and add some custom fields for this specific model, I’ve got this message from Odoo.sh :

Many2many fields my_model.channel_ids and res.partner.channel_ids use the same table and columns
 

I think I understand the message, it’s due to the fact that as I inherit from res.partner, and res.partner use channels (with mail.thread), there is a problem with column names.

But I’m wondering :

1) how can I solve this ? Do I have to rewrite everything about the message/channels ?? It would make a lot of work !

2) is there any way to handle this « automatically » ?

I even tried to add mail.thread in inherit, but no change


Here is an exemple :

from odoo import models, fields, api, _


class Trainer(models.Model):

_inherit=['res.partner','mail.thread']

_name = 'trainer'


[...custom fields...]


Error : Many2many trainer.channel_ids and res.partner.channel_ids use the same table and columns

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,



The issue is because of res.partner and your custom class using same table (mail_channel_partner) so that it is throwing error. to avoid that we have to create new table(mail_channel_profile_partner). Create one more many2many field in your custom module. like following.


channel_ids = fields.Many2many('mail.channel, 'mail_channel_profile_partner', 'partner_id', 'channel_id', copy=false)

อวตาร
ละทิ้ง

This solved the problem. Thanks

คำตอบที่ดีที่สุด

Hello @Pierre, have you found the solution to this issue, i have the same.

my code works fine in Odoo11, now i'm trying to migrate it to Odoo13 and get this error

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
that's because you specified "relation=xxx" on multiple models. A relation table can only be used for one model. use relation=ABC for model A and relation=XYZ for model B
อวตาร
ละทิ้ง

how to solve this issue. i have in inherited class (sale order line) only in my custom class (sale order line child).I dont have any fields defined on that,still i m getting this error.

Change relation name in your model

Related Posts ตอบกลับ มุมมอง กิจกรรม
5
มิ.ย. 20
9304
1
ก.ค. 25
1731
4
เม.ย. 25
12109
1
ก.พ. 25
3489
1
ม.ค. 25
1382