Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
28844 Zobrazení

Explaination of Odoo domain filter with simple example

Avatar
Zrušit

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 Nejlepší odpověď

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'))


Avatar
Zrušit

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.

Nejlepší odpověď

Yanthee This link no longer works

Avatar
Zrušit

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

Related Posts Odpovědi Zobrazení Aktivita
4
pro 24
15434
2
bře 23
3952
1
úno 25
15287
0
kvě 21
15
1
kvě 25
434