تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
5776 أدوات العرض

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?

الكاتب

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

أفضل إجابة

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 '>'.

 

الصورة الرمزية
إهمال
أفضل إجابة

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

Thanks.

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

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

 

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مارس 15
4376
6
يناير 17
15469
1
سبتمبر 15
9801
1
أبريل 15
3139
1
يناير 25
8450