Search 1.9 billion lines of Odoo code on GitHub

pos_self_service_print_zpl

Author: Coop IT Easy SCRLfs, Odoo Community Association (OCA)
License: AGPL-3
Branch: 12.0-add-pos_self_service_print_zpl
Repository: coopiteasy/pos
Dependencies: point_of_sale, and pos_self_service_base
Languages: HTML (459, 3.6%), JavaScript (12212, 94.8%), Python (51, 0.4%), XML (54, 0.4%), and reStructuredText (105, 0.8%)

<h1 class="title">Point Of Sale - Self-Service Print ZPL</h1> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/coopiteasy/addons/tree/12.0/pos_self_service_print_zpl"><img alt="coopiteasy/addons" src="https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github" /></a></p> <p>This module handles barcode printing from the browser, using ZPL.</p> <p><strong>Table of contents</strong></p> <div class="contents local topic" id="contents"> <ul class="simple"> <li><a class="reference internal" href="#configuration" id="id1">Configuration</a><ul> <li><a class="reference internal" href="#printer" id="id2">Printer</a></li> <li><a class="reference internal" href="#reverse-proxy-with-nginx" id="id3">Reverse proxy with nginx</a></li> </ul> </li> <li><a class="reference internal" href="#usage" id="id4">Usage</a></li> <li><a class="reference internal" href="#development" id="id5">Development</a></li> <li><a class="reference internal" href="#bug-tracker" id="id6">Bug Tracker</a></li> <li><a class="reference internal" href="#credits" id="id7">Credits</a><ul> <li><a class="reference internal" href="#authors" id="id8">Authors</a></li> <li><a class="reference internal" href="#contributors" id="id9">Contributors</a></li> <li><a class="reference internal" href="#maintainers" id="id10">Maintainers</a></li> </ul> </li> </ul> </div> <a name="configuration"></a> <h2><a class="toc-backref" href="#id1">Configuration</a></h2> <a name="printer"></a> <h3><a class="toc-backref" href="#id2">Printer</a></h3> <p>Add printer to the OS.</p> <p>Browse to the CUPS configuration page to get the name of the printer that will be used: <a class="reference external" href="http://localhost:631/printers">http://localhost:631/printers</a>. Set this name as the printer name in the POS self-service configuration page.</p> <p>Center the barcode by trial and error using the label offset and size configuration values of the POS self-service configuration page.</p> <p>Configure printer to accept several jobs in a row:</p> <pre> <code>lpadmin -p &lt;PRINTERNAME&gt; -o usb-no-reattach-default=true</code> </pre> <p>And restart CUPS to apply the new configuration:</p> <pre> <code>sudo service cups restart</code> </pre> <a name="reverse-proxy-with-nginx"></a> <h3><a class="toc-backref" href="#id3">Reverse proxy with nginx</a></h3> <p>Install nginx:</p> <pre> <code>apt install nginx</code> </pre> <p>Start nginx:</p> <pre> <code>sudo systemctl start nginx.service</code> </pre> <p>Copy this file in:</p> <pre> <code>/etc/nginx/sites-available/cups</code> </pre> <pre class="code"> <code class="code">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; } }</code> </pre> <p>Create symbolic link:</p> <pre> <code>sudo ln -s /etc/nginx/sites-available/cups /etc/nginx/sites-enabled/</code> </pre> <p>Check the syntax is ok:</p> <pre> <code>sudo nginx -t sudo systemctl restart nginx.service</code> </pre> <a name="usage"></a> <h2 class="with-subtitle"><a class="toc-backref" href="#id4">Usage</a></h2> <h2 class="section-subtitle" id="reset-a-zebra-printer"><span class="section-subtitle">Reset a Zebra printer</span></h2> <p><a class="reference external" href="https://www.youtube.com/watch?v=SXvoW3sm6ls">Factory reset video</a></p> <a name="development"></a> <h2 class="with-subtitle"><a class="toc-backref" href="#id5">Development</a></h2> <h2 class="section-subtitle" id="generate-javascript-bundle-file"><span class="section-subtitle">Generate JavaScript bundle file</span></h2> <p>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:</p> <pre> <code>npm -i ipp npm -g browserify browserify static/src/js/print.js -o static/src/js/bundle.js</code> </pre> <a name="bug-tracker"></a> <h2><a class="toc-backref" href="#id6">Bug Tracker</a></h2> <p>Bugs are tracked on <a class="reference external" href="https://github.com/coopiteasy/addons/issues">GitHub Issues</a>. 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 <a class="reference external" href="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**">feedback</a>.</p> <p>Do not contact contributors directly about support or help with technical issues.</p> <a name="credits"></a> <h2><a class="toc-backref" href="#id7">Credits</a></h2> <a name="authors"></a> <h3><a class="toc-backref" href="#id8">Authors</a></h3> <ul class="simple"> <li>Coop IT Easy SCRLfs</li> </ul> <a name="contributors"></a> <h3><a class="toc-backref" href="#id9">Contributors</a></h3> <ul class="simple"> <li><dl class="first docutils"> <dt><a class="reference external" href="https://coopiteasy.be">Coop IT Easy SCRLfs</a>:</dt> <dd><ul class="first last"> <li>Grégoire Leeuwerck &lt;<a class="reference external" href="mailto:gregoire&#64;coopiteasy.be">gregoire&#64;coopiteasy.be</a>&gt;</li> <li>Vincent Van Rossem &lt;<a class="reference external" href="mailto:vincent&#64;coopiteasy.be">vincent&#64;coopiteasy.be</a>&gt;</li> </ul> </dd> </dl> </li> <li><dl class="first docutils"> <dt><a class="reference external" href="https://lenid.ch">Le Nid</a>:</dt> <dd><ul class="first last"> <li>François Kawala</li> </ul> </dd> </dl> </li> </ul> <a name="maintainers"></a> <h3><a class="toc-backref" href="#id10">Maintainers</a></h3> <p>This module is part of the <a class="reference external" href="https://github.com/coopiteasy/addons/tree/12.0/pos_self_service_print_zpl">coopiteasy/addons</a> project on GitHub.</p> <p>You are welcome to contribute.</p>