Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4321 มุมมอง

Hi, 

I need to get the ids of the invoices between an interval with the start date and end date inclusive, and from this just the invoices in state paid , and type in_refund ?

I've like this :  

invoice_obj.search(cr, uid,[('date_invoice', '>=', date_from ),('date_invoice', '<=', date_to),('type','in', ['in_refund']),('state','=','paid') ])

But the result isn't the expected. 

What is the way to do it?
Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Serach method are using polish notation . basicly when you do some_obj.search(cr, uid, [ XXXX ])

Now.. [ XXX] can contain only one comparation.. like [ ('date_invoice','>=', date_from )] .. that is easy... 
If more then one comparation tuple is needed, then you need to put extra logical operators wich are: '|' = OR, '&' = AND ...

In your case, i would write search like this:
['&','&','&',('date_invoice', '>=', date_from ),('date_invoice', '<=', date_to),('type','in', ['in_refund']),('state','=','paid') ]

in order to serach for records that sattisfy ALL condition tuples, the way you wrote it will be interpreted as:

[('date_invoice', '>=', date_from ) OR ('date_invoice', '<=', date_to) OR ('type','in', ['in_refund']) OR ('state','=','paid') ]

 

I hope this will help a bit

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

use this:

invoice_obj.search(cr, uid,['&','&','&',('date_invoice', '>=', date_from ),('date_invoice', '<=', date_to),('type','in', ['in_refund']),('state','=','paid') ])

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Search within a period of date แก้ไขแล้ว
22
ธ.ค. 23
49523
8
ก.ค. 24
16354
2
มี.ค. 15
5769
0
มี.ค. 15
8470
1
มี.ค. 15
3948