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

hello,
i'm trying to but all records  in one table, but instead each record will be printed as separate table. how could i have all records in one table instead table for each record.
Thanks for your help  

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

Hi Abdulkader,
Perhaps you are looping over the table instead of <tr> tag.

Tác giả

hello Kalkivi
this is the code that i wrote.
<template id="report_price_posters">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="product_tmpl_id">

<style>
.head {
background-color : #2d3436 ;
color :black;
}
.inside_cell {
background-color : #2980b9;
color: white;
}
.description {
text-align: left;
}
</style>
<table class="table">
<thead class="head">
<tr>
<th>Product Name</th>
<th>Description</th>
<th>Quantity</th>
<th>Price €</th>
</tr>

</thead>
<tbody>
<t t-foreach="product_tmpl_id" t-as="product_line_id">
<tr class="inside_cell">
<td t-esc="product_line_id.name"/>
<td t-esc="product_line_id.description"/>
<td t-esc="product_line_id.quantity"/>
<td t-esc="product_line_id.list_price"/>
</tr>
<tr>
<td style="height:100;width:100;">
<img t-att-src="image_data_uri(product_tmpl_id.image_1920)" hight="200"
width="200"/>
</td>
<td class="description">
<t t-esc="product_line_id.description_2"/>
</td>
<td>
</td>
<td>
</td>
</tr>
</t>
</tbody>
</table>
</t>
</t>
</template>

Can try with the below snippet?

<template id="report_price_posters">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="product_tmpl_id">
<t t-call="web.external_layout">
<div class="page">
<style>
.head {
background-color : #2d3436 ;
color :black;
}
.inside_cell {
background-color : #2980b9;
color: white;
}
.description {
text-align: left;
}
</style>
<div class="row">
<div class="col-12">
<table class="table table-bordered">
<thead style="display: table-row-group">
<tr>
<th class="text-center" style="width: 25%" scope="col">Product Name</th>
<th class="text-center" style="width: 25%" scope="col">Description</th>
<th class="text-center" style="width: 25%" scope="col">Quantity</th>
<th class="text-center" style="width: 25%" scope="col">Price €</th>
</tr>
</thead>
<tbody>
<t t-foreach="product_tmpl_id" t-as="product_line_id">
<tr class="inside_cell">
<td t-esc="product_line_id.name"/>
<td t-esc="product_line_id.description"/>
<td t-esc="product_line_id.quantity"/>
<td t-esc="product_line_id.list_price"/>
</tr>
<tr>
<td>
<img t-att-src="image_data_uri(product_tmpl_id.image_1920)" hight="200"
width="200"/>
</td>
<td class="description">
<t t-esc="product_line_id.description_2"/>
</td>
<td>
</td>
<td>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</div>
</t>
</div>
</t>
</t>
</t>
</template>

Tác giả

i think this code will print the each record in a new
table in separate page and i want them in one page.

Tác giả

thank u anyway Kalkivi

Tác giả Câu trả lời hay nhất

hello Kalkivi.
FYI i solved the proplem and i wanted to share the result with u
the proplem was i had two Loops in the code which shouldn't be.
the functional code is :
<template id="report_price_posters">
<t t-call="web.html_container">
<t t-set="product_tmpl_id" t-value="docs"/>
<div class="">
<style>
.head {
background-color : #2d3436 ;
color :white;
}
.inside_cell {
background-color : #2980b9;
color: white;
}
.description {
text-align: left;
}
</style>
<div class="row">
<div class="col-12">
<table class="table table-bordered">
<t>
<tr class="head">
<th class="text-center" style="width: 25%" scope="col">Product Name</th>
<th class="text-center" style="width: 25%" scope="col">Description</th>
<th class="text-center" style="width: 25%" scope="col">Quantity</th>
<th class="text-center" style="width: 25%" scope="col">Price €</th>
</tr>
</t>
<tbody>
<t t-foreach="product_tmpl_id" t-as="product_line_id">
<tr class="inside_cell">
<td t-esc="product_line_id.name"/>
<td t-esc="product_line_id.description"/>
<td t-esc="product_line_id.quantity"/>
<td t-esc="product_line_id.list_price"/>
</tr>
<tr>
<td>
<img t-att-src="image_data_uri(product_line_id.image_1920)"
hight="200"
width="200"/>
</td>
<td class="description">
<t t-esc="product_line_id.description_2"/>
</td>
<td>
</td>
<td>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</div>
</div>
</t>
</template>
and i want to thank u for taking some of your time trying to help me :D

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

Thank you for letting me know

Tác giả

welcome

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 1 25
44681
0
thg 10 24
1510
0
thg 10 24
5
2
thg 7 23
6374
1
thg 6 23
4363