Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged

This is one of my report template, but these product images are not visible , and These rows are too near to each and How can I customize this as much as possible? And How Can I  Improve the report look? I am a beginner,

<odoo>
<!-- Inherit the Pro-forma report template -->
<template id="proforma_invoice_report_custom">
<t t-call="company_sale_proforma_invoice_layout.proforma_common_layout">
<t t-set="company" t-value="doc.company_id"/>
<table style="width:100%; border:1pt solid black; border-collapse:collapse; margin-top:20px;">
<thead>
<tr>
<th style="border:1pt solid black;">Image</th>
<th style="border:1pt solid black;">Product</th>
<th style="border:1pt solid black;">Description</th>
<th style="border:1pt solid black;">Quantity</th>
<th style="border:1pt solid black;">Unit Price</th>
<th style="border:1pt solid black;">Discount (%)</th>
<th style="border:1pt solid black;">Subtotal</th>
</tr>
</thead>
<tbody>
<tr t-foreach="doc.order_line" t-as="line">
<!-- Product Image -->
<td style="border:1pt solid black; text-align:center;">
<img t-if="line.product_id.image_1024"
t-att-src="'data:image/png;base64,%s' % line.product_id.image_1024"
style="max-height:45px; max-width:90px;"/>
</td>
<!-- Product Name -->
<td style="border:1pt solid black;">
<t t-esc="line.product_id.display_name"/>
</td>
<!-- Description -->
<td style="border:1pt solid black;">
<t t-esc="line.name"/>
</td>
<!-- Quantity -->
<td style="border:1pt solid black; text-align:right;">
<t t-esc="line.product_uom_qty"/>
</td>
<!-- Unit Price -->
<td style="border:1pt solid black; text-align:right;">
<t t-esc="line.price_unit"
t-options="{'widget': 'monetary', 'display_currency': doc.currency_id}"/>
</td>
<!-- Discount -->
<td style="border:1pt solid black; text-align:right;">
<t t-esc="line.discount"
t-options="{'widget': 'monetary', 'display_currency':doc.currency_id}"/>
</td>
<!-- Subtotal -->
<td style="border:1pt solid black; text-align:right;">
<t t-esc="line.price_subtotal"
t-options="{'widget':'monetary', 'display_currency':doc.currency_id}"/>
</td>
</tr>
</tbody>
</table>
</t>
</template>
</odoo>
Avatar
Opusti
Best Answer

Hi,


To add the image to the template, try the following code

<!-- Product Image -->
<td style="border:1pt solid black; text-align:center;">
<img t-if="line.product_id.image_1024"
t-att-src="image_data_uri(line.product_id.image_1024)"
style="max-height:45px; max-width:90px;"/>
</td>


To adjust the width of a table column, we need to use inline styles.

<th style="width: 30%;">Image</th>
<th style="width: 50px;">Product</th>

Add width to all columns.


Hope it helps.

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
jun. 25
732
2
feb. 25
1941
0
dec. 24
1325
2
feb. 25
1490
0
okt. 24
2072