コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
30372 ビュー

Explaination of Odoo domain filter with simple example

アバター
破棄

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"]]

著作者 最善の回答

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


アバター
破棄

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.

著作者

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.

最善の回答

Yanthee This link no longer works

アバター
破棄

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

関連投稿 返信 ビュー 活動
4
12月 24
16506
2
3月 23
4411
1
2月 25
16256
0
5月 21
15
1
5月 25
885