Foreign key (many-to-one) filters


I’m looking for a way to restrict a foreign key filed to a subset of the target table. For example, in a Customer field, I want to allow only Partners that have a isCustomer attribute set to true:

<many-to-one name=“customer” ref=“my.package.db.Partner” …only customer partners… title=“Customer”/>

I can’t find this in the docs, but I’m sure I’m missing something…

Could someone point me to the relevant resource?


You’ve to use the domain clause on the UI


You can have a look here and a sample can be found in menu.XML of axelor-cm

self.isContact = true AND self.mainPartner.isCustomer = true

U need to specify a jpql clause in a domain node

So if I’m not misunderstanding, this will add a filter in the view, but will not enforce the constraint at the db level.
That might be enough for my use case, but it’s just to be sure.

yes, you’re right.