Query field domain based on a form input

Hello,

I have a form field with domain where jsonModel equals a constant. I need to add a condition based on another field in the same form.

Currently I have
<field name="$attrs.sales" title=“Sales” x-type= “many-to-one” domain="self.jsonModel=‘Person’ and self.attrs.Person.name = value_from_another_field />

What should value_from_another_field be ?

Thanks.

You can use the field name with : prefix. The field name is than used as a query parameter:

<field name="$attrs.sales" title=“Sales” x-type= “many-to-one” domain="self.jsonModel=‘Person’ and self.attrs.Person.name = :name_of_the_field" />

I’ve got: Invalid domain: self.jsonModel=‘Person’ and self.attrs.Person.name = :$attrs.first.

Here my other field name is $attrs.first.

Thank you.

That won’t work as it’s not a valid query param. You can only use direct field names. However, for custom fields are exception, you can refer them directly. Also, you have to use json_extract function (this is undocumented at the moment).

self.jsonModel=‘Person’ and json_extract(self.attrs, 'Person', 'name') = :first