Skip to Content
Menu
This question has been flagged
1 Reply
1813 Views

Version 16.  We have a lot of incoming items that we have to track by serial number.  I want to create barcode labels with the serial number to put on the boxes (1 item per box).  Is there a way to add that info to the barcode labels? Also on some items I need to include our at number plus the vendor part number.  I do not see how to do that either.  Right now I have export templates that I bring into the dymo app but it is a lot of extra steps.  Thanks in advance.

Avatar
Discard
Best Answer

Hello,

For creating barcode labels with the serial number you need to create a button in ' stock.lot ' model, please refer this below code for button function.

def generate_barcode(self):
for record in self:
data = {
'response': record.name,
}
return self.env.ref('module_name.action_for_barcode').report_action(self, data=data)

In xml file in data folder, create a action for triggering this barcode

<record id="action_for_barcode" model="ir.actions.report">


    <field name="name">action_barcode</field>


    <field name="model">my.barcode</field>


    <field name="report_type">qweb-pdf</field>


    <field name="report_name">module_name.template_name</field>


    <field name="report_file">module_name.template_name</field>


</record>


And finally create a template for generating barcode

<template id="template_name">


    <t t-call="web.basic_layout">


        <div class="page">


            <div class="col-md-6">


                <img class="barcode" t-att-src="'/report/barcode/?barcode_type=%s&value=%s&width=%s&height=%s&humanreadable=1&quiet=0'


 % ('Code128',response, 205, 67)" alt="Barcode"/>


            </div>


        </div>


    </t>


</template>

in this way you can create barcode with serial number.

Regards

Avatar
Discard