跳至内容
菜单
此问题已终结

I have tried to solve this but I can't get the domain to run correctly. I am using Odoo 13

I have 3 models defined in the following way, I tried to make it clear and simplified, sorry if I missed any syntax errors but here are the relevant fields and classes:

class A(models.Model):
_rec_name = 'num'

num = fields.Integer(required=True)

class B(models.Model):

b_a = fields.Many2one('my_module.a', required=True, related='other.o_a')

b_c = fields.Many2one('my_module.c', ondelete='set null')

class C(models.Model):

c_b = fields.One2many('my_module.b', inverse_name='b_c')

c_a = fields.Many2Many('my_module.a', domain = [('num', '=', [('num', 'in', c_b.b_a)] )] )

So, I need c_a to be limited only to a's that can be found in their corresponding b's. Something like


c_a = [b.b_a for b in c_b]

What is the correct way to set this domain? When I use the one I set in the code I get a recursion depth exceeded error. When I use something like that comprehension I get that c_b is not iterable?!?

Thank you for your time.

形象
丢弃
编写者 最佳答案

I realized I had approached the problem the wrong way. I ended up making c_a a computed field and c_b was restricted in the view instead of the model to only be able to chose b's where <field name="c_b" widget="many2many" domain="[('b_c', '=', None)]">

形象
丢弃
相关帖文 回复 查看 活动
0
3月 23
2193
1
12月 22
2291
3
5月 24
7939
0
11月 22
80
1
6月 22
7281