Skip to Content
Menu
This question has been flagged

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.

Avatar
Discard
Author Best Answer

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)]">

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 23
1089
1
Dec 22
1284
3
May 24
6556
0
Nov 22
80
1
Jun 22
5676