Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
4330 Prikazi

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

Avatar
Opusti
Best Answer

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

Avatar
Opusti
Best Answer

use this:

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

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
22
dec. 23
49552
8
jul. 24
16357
2
mar. 15
5781
0
mar. 15
8482
1
mar. 15
3955