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

I have two custom modules. In module A, I have a One2many relation to a model in module B, and in module B, I have a Many2one relation to the model in module A.

However, this creates a dependency issue, as both modules cannot depend on each other.

I tried adding module B as a dependency in module A __manifest__.py, and vice versa, but this doesn't work, and the modules don't install. 

Is there a way to do this?

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

Hi  Brandon Chetty,

Add B in A's  __manifest__.py.

inherit B's model and add  Many2one relation  in Module A  itself.


In Module A

class A(models.Model):
_name = "A.A"

name = fields.Char("Name")
b_lines = fields.One2many('B.B', 'a_id')

class B(models.Model):
_inherit = "B.B"

a_id = fields.Many2one('A.A')


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ธ.ค. 23
6838
Doubt about module แก้ไขแล้ว
2
พ.ค. 22
1947
Modules - Order of dependencies แก้ไขแล้ว
1
ก.ย. 21
10495
1
เม.ย. 23
2787
1
ธ.ค. 22
2895