Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
30255 Lượt xem

Explaination of Odoo domain filter with simple example

Ảnh đại diện
Huỷ bỏ

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

Tác giả Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ

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.

Tác giả

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.

Câu trả lời hay nhất

Yanthee This link no longer works

Ảnh đại diện
Huỷ bỏ

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 12 24
16415
2
thg 3 23
4358
1
thg 2 25
16174
0
thg 5 21
15
1
thg 5 25
850