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

I want to define domain like this 

domain = A and B or C or (D and E)

name : fields.many2one('stock.production.lot,'No Engine',domain="[('branch_id','=',parent.branch_id),('tgl_penyerahan_bpkb','=',False),'|',('finco_id','=',parent.partner_id),('customer_id','=',parent.partner_id),('finco_id','=',False)]"),    

but it didn't show up , anyone can solve it ? Thanks in advance

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

The operators in the domain are prefix. Prefix notation requires the operators to be placed first and then the operands. This means that A and B should be translated in the prefix expression as and A B. Following this form, and based on you expression, this is the way to convert it to prefix and than writhe the domain:

A and B or C or (D and E) => and A B or C or (D and E) => or and A B C or (D and E) => or or and A B C (D and E) => or or and A B C and D E

So, the expression you need to write is or or and A B C and D E. There is convention that and can be omitted, so the final expression is:

or or A B C D E  which in code is ['|','|',('branch_id','=',parent.branch_id),('tgl_penyerahan_bpkb','=',False),('finco_id','=',parent.partner_id),('customer_id','=',parent.partner_id),('finco_id','=',False)]

I hope this helps. Prefix notation can be confusing for a first time, so here is a site that can help you understand the notation http://www.cs.man.ac.uk/~pjj/cs212/fix.html

Ảnh đại diện
Huỷ bỏ
Tác giả

actually my real code is like this " A and B and C and D or E or (F and G) " , how can i implement it ? it so confuse .. thank you

A and B and C and D or E or (F and G) => or or and and and A B C D E and F G

Tác giả

ok i'll try it

Tác giả

domain="['|','|','&','&','&',('penerimaan_bpkb_id','!=',False),('state_stnk','=','proses_stnk'),('branch_id','=',parent.branch_id),('tgl_penyerahan_bpkb','=',False),('finco_id','=',parent.partner_id),'&',('customer_id','=',parent.partner_id),('finco_id','=',False)]", It still didn't work , the field filtering data even the customer_id is not what i select in parent menu ..

Check if your initial expression is correct. The A and B or C means (A and B) or C, so first A and B is evaluated. With other words, your expression can be read as (A and B and C and D) or (E) or (F and G), so if one of this three groups is true, the record will be presented.

Tác giả

yes Jordan , did i write the right code for it?

Tác giả

thanks for your answer ,,,

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

  Following is the example to implement the domain = A and B or C or (D and E)

domain = ['|', '|', '&', ('branch_id','=',parent.branch_id), ('tgl_penyerahan_bpkb','=',False), ('finco_id','=',parent.partner_id),
                        '&', ('customer_id','=',parent.partner_id), ('finco_id','=',False)]

--->Hope this help you

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

i write this , domain="['&','&','&',('penerimaan_bpkb_id','!=',False),('state_stnk','=','proses_stnk'),('branch_id','=',parent.branch_id),('tgl_penyerahan_bpkb','=',False),'|',('finco_id','=',parent.partner_id),'&',('customer_id','=',parent.partner_id),('finco_id','=',False)]" and it works ..

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