Update of Snippets

This commit is contained in:
Kurt Gisler committed 2025-10-09 09:08:51 +02:00
1 parent 8ae080382f
commit 4c43f8d93f
2 files changed
+63 -24

No files matched your search

@@ -7,7 +7,7 @@
padding-right: 0px !important;
padding-left: 0px !important;
margin: 0px !important;
}
}
</style>
<t t-foreach="docs" t-as="o">
@@ -16,34 +16,63 @@
<t t-call="web.basic_layout">
<t t-call="web.html_container">
<div>
<table style="width: 100%;">
<table style="width: 100%; background-color: white; border-color: white">
<!-- Section 1: Logo -->
<tr>
<td>
<div>
<div class="text-center">
<span>
<img t-att-src="'/web/image/673'" style="height: 60px; margin-top: 20px" alt="Logo"/>
</span>
</div>
<t t-set="name_text" t-value="o.name or ''"/>
<t t-set="name_len" t-value="len(name_text) if name_text else 1"/>
<t t-set="font_size" t-value="min(160, max(20, int(500 / name_len * 2)))"/>
<div style="max-width:500px; margin:0 auto; height:240px; text-align:center;">
<table style="width:100%; height:100%;">
<tr>
<td style="vertical-align:middle;">
<span t-field="o.name" t-att-style="'display:inline-block; white-space:nowrap; font-size: {}px;'.format(font_size)">
</span>
</td>
</tr>
</table>
</div>
<div class="text-center">
<span t-if="o.barcode" t-field="o.barcode" style="margin-bottom: 10px;" t-options="{'widget': 'barcode', 'humanreadable': 0, 'symbology': 'auto', 'img_style': 'width:120mm;height:20mm; margin-bottom: 20px'}">1234567890</span>
</div>
<div class="text-center">
<span>
<!-- URL according to attachment id -->
<img t-att-src="'/web/image/673'" style="height: 5mm; margin-top: 10px" alt="Logo"/>
</span>
</div>
</td>
</tr>
<!-- Section 2: name (font-size in relation to text length) -->
<tr>
<td style="background-color: white">
<t t-set="name_text" t-value="o.name or ''"/>
<t t-set="name_len" t-value="len(name_text) if name_text else 1"/>
<t t-set="max_font_size" t-value="int(30 * 3.78)"/>
<t t-set="font_size" t-value="min(min(140, max(20, int(450 / name_len * 2))), max_font_size)"/>
<t t-set="line_height" t-value="int(font_size * 1.1)"/>
<!-- Fix height at 38 mm -->
<div style="margin:0 auto; min-height:38mm; max-height:38mm; height:38mm; text-align:center; overflow:hidden;">
<table style="width:100%; height:100%; border-collapse:collapse;">
<tr>
<td style="vertical-align:middle; text-align:center;">
<span t-out="o.name"
t-att-style="'display:inline-block; white-space:nowrap; overflow:hidden; font-size:{}px; line-height:{}px;'.format(font_size, line_height)">
</span>
</td>
</tr>
</table>
</div>
</td>
</tr>
<!-- Show variables for debugging -->
<!--
<tr>
<td>
<div class="text-center">
Schriftgröße: <t t-esc="font_size"/> px /
Zeilenhöhe: <t t-esc="line_height"/> px /
</div>
</td>
</tr>
-->
<!-- Section 3: Barcode -->
<tr>
<td>
<div class="text-center">
<span t-if="o.barcode" t-field="o.barcode" style="margin-bottom: 0px;"
t-options="{'widget': 'barcode', 'humanreadable': 0, 'symbology': 'auto',
'img_style': 'width:50mm;height:10mm; margin-bottom: 10px'}">1234567890</span>
</div>
</td>
</tr>
</table>
</div>
</t>
@@ -0,0 +1,10 @@
<data inherit_id="web.external_layout_standard" priority="50">
<xpath expr="//div/div/img/../.." position="replace">
<div t-attf-class="header o_company_#{company.id}_layout">
<div class="row">
<img t-if="company.logo" style="max-width: 1200px; margin-top: 10px;" t-att-src="image_data_uri(company.logo)" alt="Logo"/>
<div t-if="company.report_header" t-field="company.report_header" class="o_company_tagline mw-50 fw-bold">Company tagline</div>
</div>
</div>
</xpath>
</data>