Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Is there a way to filter lines in RML reports containing specific words or characters?

By
Santi
on 5/8/14, 10:12 AM 1,719 views

How can I use the python function "filter" to filter out lines in an RML report containing specific words or characters?

In my case, I would like to filter out from Invoice and Picking reports, lines containing the character ">" (this character is applied by the product_pack module to the "Children" product lines of a "Product Pack" )

This is an example of the function that appears in OpenERP's manual:

repeatIn(filter( lambda l: l.product_id.type=='service' ,o.invoice_line), 'line')

care to past the code here?

JC
on 6/21/14, 7:21 AM

sorry, I didn't see your comment till now, I already received the answer below, but thanks anyway!

Santi
on 7/16/14, 4:14 AM
1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 6/23/14, 1:46 AM

Try the below code in RML File,

[[repeatIn(filter(lambda l: l.name.find('>')==-1, o.invoice_line), 'line')]]

The above code filter the record which name column contain a character '>'.

 

1

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 6/21/14, 12:05 PM

Preferably, you should write a function which passes the lines and the function should return the filtered line to RML parser.

Thanks.

0
Santi
On 7/15/14, 11:17 AM

Perfect, thanks Prakash, that's exactly what I was looking for! ..for some reason I didn't get notified, so I hadn't seen your answer till now.

I made a slight correction to your code ('l' instead of 'line' at the end): 

[[repeatIn(filter(lambda l: l.name.find('>')==-1, o.invoice_line), 'l')]]

 

Another quick question...how can I merge two filters? 

This one: [[repeatIn(filter(lambda l: l.x_printable_choice==0 ,o.invoice_line), 'l')]]

and the one above: [[repeatIn(filter(lambda l: l.name.find('>')==-1, o.invoice_line), 'l')]]

 

I'm not sure if I should start a new thread with the question...let me know if so

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 5/8/14, 10:12 AM
Seen: 1719 times
Last updated: 3/16/15, 8:10 AM