Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
28975 Vizualizări

Explaination of Odoo domain filter with simple example

Imagine profil
Abandonează

Thanks. I have a model (Agreement) that has a contact on it. I've created a many2one field on my invoice model to link invoices to agreements. What I want is if you go to select an agreement for an invoice it only shows the agreements for that contact.
I've tried [["x_studio_partner_id","=","res.partner.id"]] & [["x_studio_partner_id","=","partner.id"]] &
[["x_studio_partner_id","=","id"]]

Autor Cel mai bun răspuns

Consider the following fields in XML view.




Single condition:
Simple condition in programming:

if field1 = 10

In Odoo domain filter, it will be written as:

syntax : Each tuple in the domain has three fields -> ('field_name', 'operator', value)

field_name : a valid name of field of the object model or in the database table

operator : valid operators are =, !=, >, >=,
value : a valid value to compare with the values of field_name, depending on its type.

ie, domain = [('field1','=',10)] # where field1 should be a field in the model and 10 will be the value

or domain = [('field1','=',field2)] # where field1 and field2 should be the fields in the model



Condition AND

Simple condition in programming:

if field1 = 5 and field2 = 10



In Odoo domain filter, it will be written as:

ie, domain = [('field1','=',5),('field2','=',10)]

or domain = [('field1','=',field3),('field1','=',field3)]



Note : Note that if you don't specify any condition at the beginning and condition will be applied.



Condition OR

Simple condition in programming:

if field1 = 5 or field2 = 10

In Odoo domain filter, it will be written as:

ie, domain = ['|', ('field1','=',5),('field2','=',10)]

or domain = ['|', ('field1','=',field3),('field1','=',field3)]



Multiple Condition

Simple condition in programming:

if field1 = 5 or (field2 ! = 10 and field3 = 12)

In Odoo domain filter, it will be written as:



domain = ['|',('field1','=',5),('&',('field2','!=',10),('field3','=','12'))


Imagine profil
Abandonează

Sorry but I don't really get why you're self-asking and answering questions that have been asked and answered dozens of times before already. It also looks ridiculously similar to https://www.odoo.com/nl_NL/forum/help-1/understanding-openerp-domain-filter-58405.

Autor

Hi Yenthe,

I thought sharing my old knowledge base with the community was a good idea.

My goal is not to draw attention to myself or to take credit for anything, but just to share.

Even if some of the proposed solutions are now obsolete, they were used at one time for a version of openERP or Odoo. It can still be used for an old version. It's true that I didn't check if the information was already in the forum.

Cel mai bun răspuns

Yanthee This link no longer works

Imagine profil
Abandonează

he mistakenly added "." at the end of the url

Related Posts Răspunsuri Vizualizări Activitate
4
dec. 24
15525
2
mar. 23
3997
1
feb. 25
15357
0
mai 21
15
1
mai 25
484