İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
23097 Görünümler

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

Avatar
Vazgeç
En İyi Yanı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

Avatar
Vazgeç
Üretici

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

Üretici

ok i'll try it

Üretici

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.

Üretici

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

Üretici

thanks for your answer ,,,

En İyi Yanı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

Avatar
Vazgeç
Üretici En İyi Yanı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 ..

Avatar
Vazgeç