Skip to content

Commit

Permalink
[ADD] beesdoo_product: Add label pdf
Browse files Browse the repository at this point in the history
- Horizontal version
- Vertical Version
  • Loading branch information
tfrancoi authored and robinkeunen committed Mar 9, 2022
1 parent fa7306c commit 6fa6b75
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
1 change: 1 addition & 0 deletions beesdoo_product/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"views/sale_views.xml",
"views/assets.xml",
"views/res_config_settings.xml",
"report/label.xml",
"wizard/views/adapt_sales_price_wizard_view.xml",
"wizard/views/label_printing_utils.xml",
"security/ir.model.access.csv",
Expand Down
144 changes: 144 additions & 0 deletions beesdoo_product/report/label.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<odoo>
<report id="report_product_label" string="Etiquettes H" model="product.template"
report_type="qweb-pdf" file="beesdoo_product.product_label"
name="beesdoo_product.product_label"/>

<template id="product_label">
<t t-call="web.basic_layout">
<div class="page">
<t t-foreach="docs" t-as="template">
<t t-foreach="template.product_variant_ids" t-as="product">
<t t-call="beesdoo_product.report_simple_label">
<t t-set="product" t-value="product"/>
</t>
</t>
</t>
</div>
</t>
</template>

<template id="report_simple_label">
<div style="width: 80%; display: inline-table;height:12rem;" >
<table class="table table-bordered mb-0" style="border: 2px solid black;">
<tr>
<th class="table-active text-left" colspan="2">
<strong t-field="product.display_name"/>
</th>
</tr>
<tr>
<td style="border: 2px solid black;" >
<strong style="font-size:1.5em" t-field="product.total_with_vat" t-options="{'widget': 'monetary', 'display_currency': product.company_id.currency_id}"/>
<span style="margin-left:30px">
<t t-esc="round(product.display_weight, 3)"/>
<t t-esc="product.display_unit.name"/>
</span>
<span style="margin-left:30px">
<span t-field="product.total_with_vat_by_unit" t-options="{'widget': 'monetary', 'display_currency': product.company_id.currency_id}"/>
/
<t t-esc="product.default_reference_unit.name"/>
</span>
<div t-if="product.main_seller_id or product.total_deposit &gt; 0" style="margin-top:10px;">
<i t-if="product.main_seller_id" class="fa fa-user" aria-hidden="true">
<strong t-esc="product.main_seller_id.name"/>
</i>
<span t-if="product.total_deposit &gt; 0" style="margin-left:15px">
Cons.: <span t-field="product.total_deposit" t-options="{'widget': 'monetary', 'display_currency': product.company_id.currency_id}" />
</span>
</div>
</td>
<td t-if="product.eco_label or product.local_label or product.fair_label or product.origin_label">
<div t-if="product.eco_label">
<i class="fa fa-leaf" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.eco_label.color_code"/>
<strong t-esc="product.eco_label.name"/>
</div>
<div t-if="product.local_label">
<i class="fa fa-map-marker" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.local_label.color_code"/>
<strong t-esc="product.local_label.name"/>
</div>
<div t-if="product.fair_label">
<i class="fa fa-balance-scale" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.fair_label.color_code"/>
<strong t-esc="product.fair_label.name"/>
</div>
<div t-if="product.origin_label">
<i class="fa fa-globe" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.origin_label.color_code"/>
<strong t-esc="product.origin_label.name"/>
</div>
</td>
</tr>
</table>
</div>
</template>

<report id="report_product_label_v" string="Etiquette V" model="product.template"
report_type="qweb-pdf" file="beesdoo_product.product_label_v"
name="beesdoo_product.product_label_v"/>

<template id="product_label_v">
<t t-call="web.basic_layout">
<div class="page">
<t t-foreach="docs" t-as="template">
<t t-foreach="template.product_variant_ids" t-as="product">
<t t-call="beesdoo_product.report_simple_label_v">
<t t-set="product" t-value="product"/>
</t>
</t>
</t>
</div>
</t>
</template>

<template id="report_simple_label_v">
<div style="width: 40%; display: inline-table;height:12rem;margin-right:20px">
<table class="table table-bordered mb-0" style="border: 2px solid black;">
<tr>
<th class="table-active text-left">
<strong t-field="product.display_name"/>
</th>
</tr>
<tr>
<td>
<strong style="font-size:1.5em" t-field="product.total_with_vat" t-options="{'widget': 'monetary', 'display_currency': product.company_id.currency_id}"/>
<br />
<span style="margin-left:30px">
<t t-esc="round(product.display_weight, 3)"/>
<t t-esc="product.display_unit.name"/>
</span>
<span style="margin-left:30px">
<span t-field="product.total_with_vat_by_unit" t-options="{'widget': 'monetary', 'display_currency': product.company_id.currency_id}"/>
/
<t t-esc="product.default_reference_unit.name"/>
</span>
<div t-if="product.total_deposit &gt; 0" style="margin-left:30px">
Cons.: <span t-field="product.total_deposit" t-options="{'widget': 'monetary', 'display_currency': product.company_id.currency_id}" />
</div>
<div t-if="product.main_seller_id" style="margin-top:10px;">
<i class="fa fa-user" aria-hidden="true">
<strong t-esc="product.main_seller_id.name"/>
</i>
</div>
</td>
</tr>
<tr t-if="product.eco_label or product.local_label or product.fair_label or product.origin_label">
<td>
<div t-if="product.eco_label">
<i class="fa fa-leaf" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.eco_label.color_code"/>
<strong t-esc="product.eco_label.name"/>
</div>
<div t-if="product.local_label">
<i class="fa fa-map-marker" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.local_label.color_code"/>
<strong t-esc="product.local_label.name"/>
</div>
<div t-if="product.fair_label">
<i class="fa fa-balance-scale" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.fair_label.color_code"/>
<strong t-esc="product.fair_label.name"/>
</div>
<div t-if="product.origin_label">
<i class="fa fa-globe" aria-hidden="true" t-att-style="'color:%s;width:18px' % product.origin_label.color_code"/>
<strong t-esc="product.origin_label.name"/>
</div>
</td>
</tr>
</table>
</div>
</template>
</odoo>

0 comments on commit 6fa6b75

Please sign in to comment.