Odoo Direct Print to Dot Matrix Printer

Introduction

  • this is module is used to print PO, SO, Picking, Invoice directly to dot matrix printer

  • no special hardware needed

  • using printer proxy script (example apache/ngnix+php) or any webserver

  • add printer_data field on account.invoice, sale.order, purchase.order, stock.picking

  • printer template data from email.template named “Dot Matrix *”

  • you can easily modify the template to adjust your printed documents, just like other Odoo’s jinja template

 

One of the biggest challange in implementing Odoo in some companies especially Indonesia which already have so many daily transactions (like thousands of invoices per day), is printing to Dot Matrix Printer!

Yes, it is common in Indonesia’s big trading companies to use Dot Matrix printer to print PO, SO, Invoices, Picking List to efficiently print using continuous and carbonised forms so they can print 3-4 document at once. Printing PDF file to dot matrix printers that can take the whole day just to print šŸ™

This can be a big issue in Odoo standard, because it uses PDF for every document printing. The print result is good when printed at deskjet/ laserjet printers, but when it comes to dot matrix, the font is broken and almost unreadable. This is because the dot per inch is too small. We can set it up bigger, but it will take some more time to print to dot matrix printer. It is impractical when it comes to print like 5000 invoices daily!

The solution is to use a proxy printing techniques. We make a small web server application at the client computer that is connected to the printer. That small application listen at a specific HTTP port and ready to receive request from Odoo’s web browser client. At server side, we add an add-on that will send the raw data to print to that local application via HTTP post. The raw data is automatically composed based on the document to print using template.

The result is: AMAZING! printing is now direct to dot matrix printer with it’s super fast speed and perfect printing result!

Mau Gratis? Only for Indonesian People šŸ™‚

Addons ini bisa anda peroleh secara gratis jika mengikuti Training Odoo di vitraining.com, klikĀ shop.vitraining.com/eventĀ untuk jadwal dan informasi lebih lanjut.

Installation

  • install this addon on the database
  • download the proxy script from this /vit_dotmatrix/static/dotmatrix.zip from the local Odoo server that you installed this add-on on.
  • install apache+php or nginx+php on the local computer and extract to above file info the htdocs folder
  • you can build your own print proxy server using python for example
  • follow the PHP Script Installation instruction below on how to install the script
  • print Invoice, SO, PO directly to local dot-matrix printer

PHP Script Installation – Windows

Install the dot-matrix printer driver from Windows Control Panel, and note the printer name for example “Epson LX-300”. Use theĀ  Generic Printer Driver, not the one from the printer driver itself.

Install XAMPP (we need only apache and PHP version 5.6.28) on client computer connected to the printer.

Download dotmatrix.zip file, extract and copy folder dotmatrix into XAMPP htdocs.

Copy file php_printer.dll into the c:\xampp\php\extension folder.

Edit file c:\xampp\php\php.ini, to enable the printer.dll, which is uncomment this line:

#extension=php_printer.dll

to become this:

extension=php_printer.dll

Modify the file print.php and set your printer name as in the Windows Control Panel:

$printername = 'Generic Printer';

Restart apache

Please check whether the extension is correctly loaded from http://localhost/xampp/phpinfo.

On Windows, make sure that you have this entry on etc/hosts file to cover CORS issues:

127.0.0.1Ā  Ā  Ā  Ā localhost

PHP Script Installation – Linux

On Linux, just edit theĀ file print.php and set your printer device file name, eg:

$printername = '/dev/usb1';

 

Sample Template Modifications

Showing Lots Number on Picking Slip

Modify the Dot Matrix Picking template to this.

.....

Products

${''.rjust(80,'-')}
${'Product'.ljust(30)} ${'Qty'.ljust(13)} ${'Lot'.ljust(13)} ${'Destination'.ljust(20)}
${''.rjust(80,'-')}
% for l in object.pack_operation_product_ids:
% set lots = []
% for x in l.pack_lot_ids:
${ lots.append( x.lot_name ) }
% endfor
${l.product_id.display_name[:30].ljust(30)} ${"{:4,.0f}".format(l.product_qty).rjust(4)} ${l.product_uom_id.name.ljust(8)} ${','.join(lots).ljust(13)} ${ l.location_dest_id.display_name.rjust(20)}
% endfor

....