Odoo Community Association

Self-Service Weighing ZPL Print Driver

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

ZPL print driver for the self-service weighing station.

This module allows to print barcode labels (generated by the self-service weighing station) using ZPL-compatible printers.

Table of contents

Configuration

Printer

Add printer to the OS.

Browse to the CUPS configuration page to get the name of the printer that will be used: http://localhost:631/printers. Set this name as the printer name in the POS self-service configuration page.

Center the barcode by trial and error using the label offset and size configuration values of the POS self-service configuration page.

Configure printer to accept several jobs in a row:

lpadmin -p <PRINTERNAME> -o usb-no-reattach-default=true

And restart CUPS to apply the new configuration:

sudo service cups restart

Reverse proxy with nginx

Install nginx:

apt install nginx

Start nginx:

sudo systemctl start nginx.service

Copy this file in:

/etc/nginx/sites-available/cups
upstream cups-reverse-proxy {
    server 127.0.0.1:631 weight=1 fail_timeout=60s;
}

server {
    # server port and name
    listen 8631;
    listen [::]:8631;
    server_name _;

    # ssl log files
    access_log /var/log/nginx/cups-access.log;
    error_log /var/log/nginx/cups-error.log;


    # increase proxy buffer to handle some Odoo web requests
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

    location / {
        proxy_pass http://cups-reverse-proxy;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;

        add_header 'Access-Control-Allow-Origin' $http_origin always;
        add_header 'Access-Control-Allow-Credentials' * always;
        add_header 'Access-Control-Allow-Methods' * always;
        add_header 'Access-Control-Allow-Headers' * always;
        # required to be able to read Authorization header in frontend
        add_header 'Access-Control-Expose-Headers' * always;

        if ($request_method = 'OPTIONS') {
            # Tell client that this pre-flight info is valid for 20 days
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            add_header 'Access-Control-Allow-Origin' $http_origin always;
            add_header 'Access-Control-Allow-Credentials' * always;
            add_header 'Access-Control-Allow-Methods' * always;
            add_header 'Access-Control-Allow-Headers' * always;
            # required to be able to read Authorization header in frontend
            add_header 'Access-Control-Expose-Headers' * always;

            return 204;
        }

        # by default, do not forward anything
        proxy_redirect off;
    }
}

Create symbolic link:

sudo ln -s /etc/nginx/sites-available/cups /etc/nginx/sites-enabled/

Check the syntax is ok:

sudo nginx -t
sudo systemctl restart nginx.service

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Coop IT Easy SC

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

This module is part of the OCA/pos project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.