Skip to Content
Menu
This question has been flagged
3 Replies
10618 Views

Does anyone know how to modify barcode template via Qweb?
I found the barcode report template for master product named as report_producttemplatebarcode. When printing to pdf, the problem is it prints as the whole page and now i would like to change the size and table of it so hopefully it will match with the sticker when printing using our barcode printer. This code below is the default barcode template from report_producttemplatebarcode Qweb :

<?xml version="1.0"?>
<t t-name="product.report_producttemplatebarcode">
<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="product.report_simple_barcode">
<t t-set="product" t-value="product"/>
</t>
</t>
</t>
</div>
</t>
</t>

I previously add <style> but nothing works.
Please advice, thank you

Avatar
Discard
Best Answer

Hi,

Please try in this template. report_simple_barcode

<template id="report_simple_barcode">
<div style="width: 32%; display: inline-table; height: 10rem;">
<table class="table table-bordered mb-0" style="border: 2px solid black;">
<tr>
<th class="table-active text-left" style="height: 4rem;">
<strong t-field="product.display_name"/>
</th>
</tr>
<tr>
<td class="text-center align-middle" style="height: 6rem;">
<t t-if="product.barcode">
<img alt="Barcode" t-if="len(product.barcode) == 13" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', product.barcode, 600, 150)" style="width:100%;height:4rem;"/>
<img alt="Barcode" t-elif="len(product.barcode) == 8" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN8', product.barcode, 600, 150)" style="width:100%;height:4rem;"/>
<img alt="Barcode" t-else="" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', product.barcode, 600, 150)" style="width:100%;height:4rem"/>
<span t-field="product.barcode"/>
</t>
<t t-else=""><span class="text-muted">No barcode available</span></t>
</td>
</tr>
</table>
</div>
</template>


Change the styles in the highlighted code as per your need.

Thanks

Avatar
Discard
Author

Dear Avinash,

Thank you for your feedback. It worked like a charm.

For future reference, i head to settings > technical > views, and then search report_simple_barcode. Then, i edit some code just like Avinash suggest.

Thank you friend!

Author

Ohh and yes, one more thing,

Just for future reference, to make print preview show exactly like my barcode paper, i head to settings > technical > Reports, and then type in search Product Barcode. Then i edit paper format to be just like my barcode template size, so it will print as should be.

Best Answer

Hello! i am new to odoo. And as a task at my job i need to fix a problem with the display after scanning. explanation: when i use the scanner "honeywell" which has a screen to display the information after scanning, the page that contains the information of the scan doesn't fit the screen. we have been trying other gagdet with a bigger resolution  (such as a tablet) to display the information after scaning and the page still doesn't fit the screen. every time after scanning we need to zoom out so the page could fit the screen and we do not want it like that, we would like the pages to fully display at the screen so the entire page would be visible without any zoom out or zoom in. Please help! 

Avatar
Discard
Best Answer

Hi,

I am trying to increase the width of the barcode (just the barcode). As I change the code, it increases the width however it goes beyond the boundaries of the label as I am unable to align the barcode to the left.

Avatar
Discard
Author

Hi Sanjeev,
Based on the code posted by Avinash above, try to change the "align-middle" to "align-left", or maybe just delete it instead.

to increase or decrease the barcode, try to reduce the style="width:100% to some numbers you find it fit.

Don't hesitate to tell back the result

Thanks for the Reply Altela,
I tried the solution but it does not work. Wish I could post the picture here.

I can increase or decrease the width however I can not align it to left or change its position at all.

Author

Could you put your code here please? maybe i can try to reproduce your issue and figure it out from my machine

<t t-name="product.report_simple_barcode">
<div style="width: 100%; display: inline-table; height: 4rem;">
<table class="table table-bordered mb-0" style="border: 2px solid black;">
<tr>
<th class="table-active text-left" style="height: 4rem;">
<strong t-field="product.display_name"/>
</th>
</tr>
<tr>
<td class="text-center align-left" style="height: 4rem;">
<t t-if="product.barcode">
Total Parts
<img alt="Barcode" t-if="len(product.barcode) == 13" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', quote_plus(product.barcode or ''), 600, 150)" style="width:100%;height:4rem;"/>
<img alt="Barcode" t-elif="len(product.barcode) == 8" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN8', quote_plus(product.barcode or ''), 600, 150)" style="width:100%;height:4rem;"/>
<img alt="Barcode" t-else="" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', quote_plus(product.barcode or ''), 600, 150)" style="width:105%;height:6rem"/>
<span t-field="product.barcode"/>
</t>
<t t-else=""><span class="text-muted">No barcode available</span></t>
</td>
</tr>
</table>
</div>
</t>

Author

Sanjev,
I successfully reproduce your problem in my machine, it's seems like there are no error but you are not configure your barcode paper report yet so it prints to a large paper size (mostly in A4 size as i already tested).

Since the answer is a bit long, i put a step-by-step on my blog. Here's the link, https://www.projectflakes.com/2022/04/how-to-customize-your-odoo-barcode.html

You might skipping the step number 3 here, please tell me the result after you done the steps

Appreciate your help Altela.
I have configured my label correctly and its fits on the label I am using 55X50. My issue is the barcode. The width of the barcode is squeezed due to the label size so the scanner I am using can not scan it. If I try to increase the width of the barcode it doesn't fit on the label because the barcode placed in the centre and I am unable to align it to the left.
If it makes sense.

Author

Understood,
In my previous experience I too had the same old problem where i tried to shrink the "barcode box" width but somehow it cannot be scanned using barcode scanner too. The farthest things i can achieve customizing barcode box is only reducing it's height, but not the width.

Since i cannot shrink it for customization in views, i played around with the output report and gladly it working good for my case. I also need a bit customization when printing it out with Google Chrome, by setting the "Scale" value to "Default" so it can be scanned.

Maybe you can try this one with chrome, as my last suggestion since i don't have any further troubleshot ideas XD

https://drive.google.com/file/d/1oOEtlRaVvtceCCvO5tztgGtkbiwZ-jvF/view?usp=sharing

Thanks for the suggestion. I will keep playing with it to see if it works, somehow.

Related Posts Replies Views Activity
0
Aug 24
203
1
Aug 24
556
2
Mar 24
522
1
Mar 24
310
0
Feb 23
916