What is the evaluation context of `attrs` and `domain` attributes in view fields?

Mohammad Alhashash

I know that all view fields are available. Also, in child objects (x2many), parent.xxxx fields are available to domain (not sure about attrs). Are functions allowed? It is not clear for me where each expression is evaluation (server/python or browser/javascript).

Are there other variables available? Are context variables accessible?

In Bug lp:920033 it was said that uid is added, but, the bug was marked later as invalid!

1 Answer
Nicolas Bessi
Best Answer


As far as I know, in attrs you can only pass OpenERP basic "domain".

The domain is parsed by the Web client. That force you to have all fields used in domain in the view event if not shown, they must be invisible fields.

The domain value must be static. attrs="{'readonly': [('my_filed_must_be_in_view', '=', 'static_value')]}"

You can not use complex function, or server related code the scope is limited to the view.


Normaly when you add a domain on a field using view definition you can use any kind of standard domain condition. [('', '=', True)]

But you have to consider your self outside of system. It means you can only do domain that will work trough an XMLRPC call.

In the domain value you can use any static value or any field value. Once again if you want to use a field that is not shown as a value, it must be present in view even if invisible.

I do not think you can use context in domain value like in ir.action domain but I will not be categoric.


1 Comment
Mohammad Alhashash

Thanks for your help. But, I was looking for a deterministic answer for the exact evaluation context of each type. I had some advances in my Javascript skills since I asked the question so I had the chance to study the issue and found that the situation is more complex than I thought at first.

For Example, record rule domains has uid and time module. OTH, view fields domains are evaluated client-side with current fields, parent.* and context in their evaluation context, except when many2one with selection widget where it is evaluated server-side with only uid and time.