Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
19000 Lượt xem

Hello Everyone,

I want to generate dynamic serial number and also generate total quantity without parser file.

here given example to more clarify.

serial no                                              product                                description                                quantity                                 Total 

1                                                          any product                              -                                           2                                              -

2                                                               -                                          -                                            2                                              -

3                                                               -                                          -                                            2                                              -

?                                                               -                                          -                                            2                                              -

?                                                               -                                          -                                            2                                              -

?                                                               -                                          -                                            2                                              -

Total quantity                  ?(12)

we can generate serial number using parser file but I want generate serial number and total quantity without parser file

Thanks in advance

Ảnh đại diện
Huỷ bỏ

I've updated my post. Hope this helps.

thank a lot @Shawn Varghese


Câu trả lời hay nhất

Do you mean that you want to dynamically compute serial numbers and quantity in qweb?

You could try something like this for serial number:

<t t-foreach="o.lines" t-as="p">
<span t-esc="p_index">
</t>

The "_index" is automatically understood by qweb to generate the index number

If you want to create your own, you could try something like:

<t t-set="i" t-value="1" /> 
<t t-foreach="o.lines" t-as="p">
<span t-esc="i">
<t t-set="i" t-value="i+1"/>
</t>


EDIT:

For adding quantity dynamically, I assume your code to display quantity looks something like this:

<t t-foreach="o.lines" t-as="p">
<span t-esc="p.quantity">

You need to initialize a variable before the loop, and simply add the quantity to it for each iteration:

<t t-set="i" t-value="0" /> 
<t t-foreach="o.lines" t-as="p">
<span t-esc="i">
<t t-set="i" t-value="i+p.quantity"/>
</t>

<t t-esc="i" />

This way you should get the quantity

Let me know if this doesn't work


Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks @Shawn this code is very help for me to generate dynamically serial number in qweb report can you little help for how to generate dynamic total quantity ?

Tác giả

Thanks again @Shawn Your updated code is fully work.Now I get the total quantity dynamically without parser file.

Thanks @Shawn "p_index" is works for me

Thanks a lot sir.

how to start from 1 with that first code

Tác giả

@ANSU,

Can you describe more please?

Câu trả lời hay nhất

Check this post

I write a more extensive explanation of qweb report parsers at:

https://www.odoo.com/es_ES/forum/help-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
1964
3
thg 6 25
1539
1
thg 5 25
2054
1
thg 4 25
2485
1
thg 2 25
1758