Odoo Help

0

How to use lambda expression in RML report

By
Vigneshwaran
on 10/13/14, 12:02 AM 992 views

I have to take the count of number of item in my invoice_line in my invoice

    <section>
        <para>[[repeatIn(o.move_lines,'line')]]</para>--------------->here I am creating the object
    <blockTable>
      <tr>
        <td>
          <para style="terp_tblheader_General_Centre1">[[ reduce(lambda x, obj: x+obj.line , list , 0 ) ]] </para>-------------------->expression to return the number of line in my invoice
        </td><t/r></blocktable></section>

so my desired output should be like this

  |  location  |          code     |        product     |     qty

       House1              10                   ipad                 1   

       House2              25                   iphone              2  

                                                          ----------------------------

                                                         total                    3 ------------------------>For this how to use lambda function..In RML report    

0
Anand Patel
On 10/13/14, 3:00 AM

Hi,

Lambda is the python function and you can use eeasily all the python function in the RML.

but if you need to count the no of lines of the invoice then you can pass one method which is called from the RML and revert the answer form the report's py file

i.e.

[[repeatIn(o.move_lines,'line')]] this is your rml loop for the invoice line. now you just need to call one method in the loop so it will count the and revert from the py side to rml and you will have your desired output

thanks for your answer, but i directly create a function in python and call it in my rml report like this, def _sum_qty(self): total = 0 for line in picking.move_lines: total+=line.product_qty str(total) print total return total

Vigneshwaran
on 10/13/14, 3:20 AM

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

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 10/13/14, 12:02 AM
Seen: 992 times
Last updated: 3/16/15, 8:10 AM