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

hello everyone ,


i have 5 date fields and i deed to print report which is 5 page. so i need if date1 is add so print page 1 , if date2 is add so print page 2 


is tahat possible or not ??


thanks in advance 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Suppose you have the fields date1, date2, date3, date4, and date5. As you mentioned, you have 5 pages in the report template. So, you can add conditions based on the date fields.
For example, if you have already placed the contents of each pages in a block like a division:

<div t-if="date1">


    <!--  Page 1 code  -->


</div>


<div t-if="date2">


    <!--  Page 2 code  -->


</div>


<div t-if="date3">


    <!--  Page 3 code  -->


</div>


<div t-if="date4">


    <!--  Page 4 code  -->


</div>


<div t-if="date5">


    <!--  Page 5 code  -->


</div>




If you don't have any such blocks, you can add one. Since it is a template, you can also use the t tag:

<t t-if="date1">


    <!--  Page 1 code  -->


</t>


<t t-if="date2">


    <!--  Page 2 code  -->


</t>


<t t-if="date3">


    <!--  Page 3 code  -->


</t>


<t t-if="date4">


    <!--  Page 4 code  -->


</t>


<t t-if="date5">


    <!--  Page 5 code  -->


</t>


Regards

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

this is not possible because i dont have 5 different pages but i add loop for pages . in my report two colums first is content and second is number . the conytent are same for all page but number are different for all pages .

So, you have a report with 2 columns. Are the numbers in the second column unique for each date? (You just mentioned that the numbers are different for all pages.) If yes, then you can add a variable in the report where you can set the value there based on the dates and use that variable within the for loop to add only matching rows. For example,
<!-- Set the number corresponding for the date in col_val. 1 to 5 is used here for example and 0 as default value -->
<t t-set="col_val" t-value="0" />
<t t-if="date1">
<t t-set="col_val" t-value="1" />
</t>
<t t-if="date2">
<t t-set="col_val" t-value="2" />
</t>
<t t-if="date3">
<t t-set="col_val" t-value="3" />
</t>
<t t-if="date4">
<t t-set="col_val" t-value="4" />
</t>
<t t-if="date5">
<t t-set="col_val" t-value="5" />
</t>

If you have used the for loop in <tr>, move it into another block and add the condition in <tr> for the table body.

<t t-foreach="rows" t-as="row">
<tr t-if="col_val == row.number">
<td><span t-esc="row.content" /></td>
<td><span t-esc="row.number" /></td>
</tr>
<t>

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
3195
1
thg 4 25
4565
2
thg 7 24
6125
1
thg 4 24
1981
1
thg 12 23
2674