Skip to content

Instantly share code, notes, and snippets.

@nhomar
Last active July 27, 2018 17:42
Show Gist options
  • Save nhomar/39ca748334fb113b7ffc604ad8eaf57b to your computer and use it in GitHub Desktop.
Save nhomar/39ca748334fb113b7ffc604ad8eaf57b to your computer and use it in GitHub Desktop.
Zebra Trick
# -*- coding: utf-8 -*-
from openerp import api, models
class ReportZebraProduct(models.AbstractModel):
_name = 'report.typ_printing_report.product_label_zebra_view'
@api.model
def render_html(self, docids, data=None):
if data is None:
data = {}
datas = {
'docs': self.env['product.product'].browse(
data.get('ids', docids)),
'qty': data.get('qty', 1)
}
return self.env['report'].render(
'typ_printing_report.product_label_zebra_view', datas)
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<data>
<report id="rack_label_zebra"
model="product.product"
string="rack zebra Label"
name="typ_printing_report.rack_label_zebra_view"
file="typ_printing_report.rack_label_zebra_view"
report_type="qweb-pdf"
usage="zebra"
/>
<template id="rack_label_zebra_view">
<t t-call="report.html_container">
<div class="page">
<p>
Another different report code sent to the zebra
</p>
<div class="code">
<t t-foreach="docs" t-as="product">
N
A50,10,0,5,1,1,N,"<t t-raw='product.default_code.upper()'/>"
A50,80,0,3,1,1,N,"<t t-raw='product.categ_id.name.upper()'/>"
A50,120,0,3,1,1,N,"<t t-raw='product.name.upper()'/>"
B50,200,0,1,2,6,40,B,<t t-if="product.ean13">"<t t-raw="product.ean13"/>"</t><t t-if="not product.ean13">"<t t-raw='product.default_code.upper()'/>"</t>
P<t t-esc="qty"/>
</t>
</div>
</div>
</t>
</template>
</data>
</odoo>
@nhomar
Copy link
Author

nhomar commented Jul 27, 2018

This need to be completed with this patch on the base_printer report.

https://github.com/Vauxoo/report-print-send/pull/2/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment