Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

6

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

By
Mohammad Alhashash
on 2/5/13, 3:54 PM 9,157 views

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!

7

Nicolas Bessi

--Nicolas Bessi--
1590
| 5 7 8
Lausanne, Switzerland
--Nicolas Bessi--
Nicolas Bessi
On 2/6/13, 7:03 AM

Attrs

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.

Domain

Normaly when you add a domain on a field using view definition you can use any kind of standard domain condition. [('invoice.partner_id.name', '=', 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.

Regards

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.

Mohammad Alhashash
on 4/11/13, 6:00 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/5/13, 3:54 PM
Seen: 9157 times
Last updated: 7/29/16, 1:57 AM