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

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    

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

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 22
6688
what is lambda in OpenERP? แก้ไขแล้ว
3
ม.ค. 21
24954
(<NewId 0x7ffaad918908>,) แก้ไขแล้ว
2
มิ.ย. 21
6406
1
ก.ค. 20
6928
1
ม.ค. 18
10709