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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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
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
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>
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Jul 24
|
3848 | ||
Insert image into a report
Solved
|
|
1
Apr 24
|
389 | |
|
1
Dec 23
|
995 | ||
|
0
Feb 24
|
1038 | ||
|
2
Aug 23
|
928 |