Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 181 additions & 0 deletions pos_self_service_print_zpl/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
======================================
Point Of Sale - Self-Service Print ZPL
======================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github
:target: https://github.com/coopiteasy/addons/tree/12.0/pos_self_service_print_zpl
:alt: coopiteasy/addons

|badge1| |badge2| |badge3|

This module handles barcode printing from the browser, using ZPL.

**Table of contents**

.. contents::
:local:

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

.. code-block::

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

Usage
=====

Reset a Zebra printer
~~~~~~~~~~~~~~~~~~~~~
`Factory reset video <https://www.youtube.com/watch?v=SXvoW3sm6ls>`_

Development
===========

Generate JavaScript bundle file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module makes use of the NPM library IPP to send http request to CUPS.
The NPM library browserify is used to generate a bundle.js file from the print.js file::

npm -i ipp
npm -g browserify
browserify static/src/js/print.js -o static/src/js/bundle.js

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/coopiteasy/addons/issues/new?body=module:%20pos_self_service_print_zpl%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Coop IT Easy SCRLfs

Contributors
~~~~~~~~~~~~

* `Coop IT Easy SCRLfs <https://coopiteasy.be>`_:
* Grégoire Leeuwerck <[email protected]>
* Vincent Van Rossem <[email protected]>
* `Le Nid <https://lenid.ch>`_:
* François Kawala

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/12.0/pos_self_service_print_zpl>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions pos_self_service_print_zpl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions pos_self_service_print_zpl/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 - Today Coop IT Easy SCRLfs (<http://www.coopiteasy.be>)
# - Grégoire Leeuwerck <[email protected]>
# - Vincent Van Rossem <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Point Of Sale - Self-Service Print ZPL",
"summary": "POS Self-Service Print ZPL from browser",
"version": "12.0.1.0.0",
"category": "Point of Sale",
"author": "Coop IT Easy SCRLfs, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"depends": ["pos_self_service_base"],
"data": ["views/templates.xml", "views/pos_config_view.xml"],
"qweb": ["static/src/xml/pos_self_service.xml"],
"installable": True,
}
1 change: 1 addition & 0 deletions pos_self_service_print_zpl/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_config
39 changes: 39 additions & 0 deletions pos_self_service_print_zpl/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from odoo import fields, models


class PosConfig(models.Model):
_inherit = "pos.config"

label_offset_x = fields.Integer(
string="Label Offset X",
required=True,
default=320,
help="Origin point of the contents in the label, X coordinate.",
)
label_offset_y = fields.Integer(
string="Label Offset Y",
required=True,
default=40,
help="Origin point of the contents in the label, Y coordinate.",
)
label_height = fields.Integer(
string="Label Height",
required=True,
default=2,
help="ZPL ^BY command argument",
)
label_width = fields.Integer(
string="Label Width",
required=True,
default=100,
help="ZPL ^BY command argument",
)
printer_name = fields.Char(
string="Printer Name", help="Find in CUPS at localhost:631/printers"
)
darkness = fields.Integer(
string="Darkness",
required=True,
default=20,
help="ZPL ~SD (set darkness) command. 0 to 30."
)
96 changes: 96 additions & 0 deletions pos_self_service_print_zpl/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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

.. code-block::

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
5 changes: 5 additions & 0 deletions pos_self_service_print_zpl/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Coop IT Easy SCRLfs <https://coopiteasy.be>`_:
* Grégoire Leeuwerck <[email protected]>
* Vincent Van Rossem <[email protected]>
* `Le Nid <https://lenid.ch>`_:
* François Kawala
1 change: 1 addition & 0 deletions pos_self_service_print_zpl/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module handles barcode printing from the browser, using ZPL.
9 changes: 9 additions & 0 deletions pos_self_service_print_zpl/readme/DEVELOP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Generate JavaScript bundle file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module makes use of the NPM library IPP to send http request to CUPS.
The NPM library browserify is used to generate a bundle.js file from the print.js file::

npm -i ipp
npm -g browserify
browserify static/src/js/print.js -o static/src/js/bundle.js
3 changes: 3 additions & 0 deletions pos_self_service_print_zpl/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Reset a Zebra printer
~~~~~~~~~~~~~~~~~~~~~
`Factory reset video <https://www.youtube.com/watch?v=SXvoW3sm6ls>`_
Loading