Enable Dark Mode!
By: Sreenath K

Validate the Delivery Order Using Barcode in Odoo 13

Technical Odoo 13 Warehouse

We are familiar with barcode - a small image of lines with bars and spaces. In odoo, barcode offers one of the excellent methods to track orders and store the product details.

Barcode is mainly used for saving time and it is reliable. Manual validation of delivery leads to some errors and barcodes eliminate the possibility of these errors. They are inexpensive, both in the case of design and printing.

If we confirm delivery and validate a huge number of products from the warehouse or somewhere, a lot of time will be wasted. So when we scan the barcode for these products using a delivery slip we can validate the order quickly.

Firstly we need to print the barcode in the delivery slip. The following code is for printing the barcode in the delivery slip.

<template id="report_delivery_extends_add_barcode"
  <xpath expr="//h2" position="before">
   <div class="row justify-content-end mb16">
        <div class="col-4" name="right_box">
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 600, 100)"
              style="width:300px;height:50px;" alt="Barcode" />

Add this as an XML file, this will print barcode in delivery slip.  

Next, you need to create a new model for scanning the barcode in the transfer in the operations menu in inventory.

For that, we must create a new model, 

Add this python code in model.py  in the folder model of file.

class AddBarcode(models.Model):
 _name = 'stock.picking.barcodes'
   barcodes = fields.Char(string='Barcode')
   # function for validate the barcode
   def barcode_validate(self):
       lines = self.env['stock.picking'].search([('name', '=', self.barcodes)])
       barcode_super = lines.button_validate()
       if lines:
           return barcode_super

Create security for the model ‘stock.picking.barcodes’ and add it in the init file.


Add XML for this model by creating action and view,

<?xml version="1.0" encoding="utf-8"?>
       <!-- Action for model stock.picking.barcodes       -->
        <record id="barcode_scanning_deliveries_action" model="ir.actions.act_window">
                   <field name="name">barcode.scanning.deliveries</field>
                   <field name="res_model">stock.picking.barcodes</field>
                   <field name="view_type">form</field>
                   <field name="view_mode">form</field>
                   <field name="help" type="html">
                         <p class="oe_view_nocontent_create">Package Fee
           <!--   View for model      -->
           <record id="barcode_scanning_deliveries_form" model="ir.ui.view">
           <field name="name">barcode.scanning.deliveries.form</field>
           <field name="model">stock.picking.barcodes</field>
           <field name="arch" type="xml">
               <form string="Barcode Delivery Form">
                       <!--    Input text field  -->
                          <field name="barcodes"/>
<!--  Validate buttons -->
   <button name="barcode_validate" string="Validate" type="object" class="btn-primary"/>
   <button string="Cancel" class="btn-secondary" special="cancel" />

And if you need to check this model is working or not you can add a temporary menu in the XML menu.

For that, you can add the following code in an XML file.

<menuitem id="barcode_scanning_deliveries_menu"
   name="Barcode Validate"

After that, we need to validate delivery slips in Transfers in Inventory.

We need to create a button near create and cancel transfers in inventory.


For creating a button near here we need to write code in JS.  

Create a file for JS and XML in the static folder and add the XML file in a manifest.

JS code:

odoo.define('barcode.barcode_button', function (require) {
"use strict";
var core = require('web.core');
var ListController = require('web.ListController');
       renderButtons: function($node) {
       this._super.apply(this, arguments);
           if (this.$buttons) {
               let barcode_button = this.$buttons.find('.oe_barcode_button');
               barcode_button && barcode_button.click(this.proxy('barcode_button')) ;
       barcode_button: function (e) {
           console.log('yay filter')
           var self = this;
           var time = $(e.currentTarget).data('start-time');
           var date = self.search_date;
               name: 'Barcode Validate',
               type: 'ir.actions.act_window',
               res_model: 'stock.picking.barcodes',
               view_mode: 'form',
               views: [[false, 'form']],
               target: 'new'

XML Code:

<template xml:space="preserve">
       <t t-extend="ListView.buttons">
           <t  t-jquery="button.o_list_button_add" t-operation="after">
               <button t-if="widget.modelName == 'stock.picking'"   type="button" class="btn btn-primary btn-sm oe_barcode_button" accesskey="f">
                   Barcode Validate

You need to give a path to the js file in views as an XML file adds its path into the manifest file.

When you complete and run this code a button will create in the transfer.


After running these all code you will see the following:


When you scan the barcode in delivery slip using the barcode scanner the Reference(WH/OUT/****) of the transfers will get in the field barcode and you can validate it.


When you click the validate button, the order will validate itself. Hence we can validate the bulk of items in a delivery order through this barcode validator button. Thus we can save the time of validating the delivery order in the warehouse or inventory

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message