0
votes

I have supply.conditions and purchase.request models. In purchase.request I have many2many relation field:

supply_ids  = fields.Many2many(comodel_name='supply.conditions', relation='purchase_supply_rel', column1='purchase_requests_id', column2='supply_conditions_id',string='Supply Conditions')

In supply.conditions model I need to add domain filter to check that supply.conditions id is in purchase_supply_rel table. I want to change SQL:

select * from supply_conditions a
inner join purchase_supply_rel b
on a.id = b.supply_conditions_id

to many2many relation domain.

I tied to make domain filter like that:

[('id', '=', purchase_supply_rel.supply_conditions_id)]

But I got an error:

ValueError: "name 'purchase_supply_rel' is not defined" while evaluating

What is wrong? Do I have to have the same many2many relation in my supply.conditions model?

1
Can you explain me better what you wish to achieve? What exactly you are filtering and where? (ex: filtering res.users in res.partner m2m field)Dachi Darchiashvili
I want to filter supply_conditions_id's which are in purchase_supply_rel table. But need to set this domain in my supply.conditions model tree viewfueggit

1 Answers

0
votes

For filtering Many2many field you can use

<field name="m2m_field" domain="[('field', '=', True)]"/>

So using domain [('id', 'in', ids)] will filter related objects as usual