Reputation: 800
I am creattng a report to print a barcode label.
My template try to print the whole page, but I need a specia page side: width = 35mm
and height = 11mm
.
So how and where can I change the default product label report template and make changes? I need to print only the label as pdf.
Upvotes: 2
Views: 2033
Reputation: 9630
The report template with the barcode, this example is uses a qrcode, but you can change it to adapt it to your needs. You can add some styles as well:
<template id="report_label_style" inherit_id="website_report.layout">
<xpath expr="//style" position="after">
<style type="text/css">
.example_class {
display: block;
width: 228px;
height: 103px;
}
</style>
</xpath>
</template>
<template id="report_label">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<div class="example_class">
<t t-set="qr_src">/report/barcode/?type=QR&value=<t t-esc="o.qr_string" />&width=600&height=600</t>
<img t-att-src="'%s' % qr_src"/>
</div>
</div>
</div>
</t>
</t>
</template>
The paperformat definition. You will see the paperformat if you go to: Settings > Report > Paper forma
<record id="paperformat_label_example" model="report.paperformat">
<field name="name">Paperformat Example</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">23</field>
<field name="page_width">50</field>
<field name="orientation">Portrait</field>
<field name="margin_top">0</field>
<field name="margin_bottom">0</field>
<field name="margin_left">0</field>
<field name="margin_right">0</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">0</field>
<field name="dpi">80</field>
</record>
The report action, this creates the needed record in the model ir_act_report_xml
:
<report id="action_report_label"
model="model.name"
report_type="qweb-pdf"
name="module_name.report_label"
file="module_name.report_label"
string="Label" />
Here I associate the paperformat to the report:
<record id="module_name.action_report_label" model="ir.actions.report.xml">
<field name="paperformat_id" ref="module_name.paperformat_label_example"/>
</record>
Upvotes: 1