-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] zpl_printer, zpl_printer_mrp, zpl_printer_stock: Adding modules…
… for direct label printing Adding the modules we use for production purposes to directly interact with zpl printers.
- Loading branch information
Showing
48 changed files
with
2,406 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../zpl_printer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../zpl_printer_mrp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../zpl_printer_stock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
====================== | ||
ZPL Printer Management | ||
====================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:b0c431522ae7a77979f8a985048da965c493f51e56dc36d1a44a38ad67656d43 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-OCA%2Freport--print--send-lightgray.png?logo=github | ||
:target: https://github.com/OCA/report-print-send/tree/16.0/zpl_printer | ||
:alt: OCA/report-print-send | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/report-print-send-16-0/report-print-send-16-0-zpl_printer | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module adds a new report type for zpl labels, in order to send them directly to a printer through a https request. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. Go to *Settings > Integrationen > Label-Printers* | ||
#. Add at least one printer as default | ||
#. If using stock or mrp modules, make sure that the connection modules | ||
zrp_printer_mrp / zrp_printer_stock are available. | ||
#. Best used in combination with a further module, that provides layouts for printers, | ||
otherwise default-layouts will be used. | ||
|
||
Usage | ||
===== | ||
|
||
This module uses https connection to a printer in your network to print to it. | ||
Assuming the printer is properly configured for this purpose, and in your network, for example as | ||
`label.my_company.local` then the printer will wait for POST requests to https://label.my_company.local/pstprnt | ||
So that would be the address that makes the printer available to Odoo. | ||
|
||
To setup your printer for this, you have to provide a certificate and enable https on the printer, | ||
which works with the following command, that you have to send to it: | ||
|
||
:: | ||
|
||
~DYE:HTTPS_CERT.nrd,B,NRD,1480,,-----BEGIN CERTIFICATE----- | ||
THIS IS THE CONTENT OF YOUR CERTIFICATE, YOU HAVE TO CREATE IT | ||
-----END CERTIFICATE----- | ||
~DYE:HTTPS_KEY.nrd,B,NRD,1704,,-----BEGIN PRIVATE KEY----- | ||
THIS IS THE CONTENT OF THE PRIVATE KEY FOR YOUR PRINTER, YOU HAVE TO CREATE IT | ||
-----END PRIVATE KEY----- | ||
^XA | ||
^JUS | ||
^XZ | ||
! U1 setvar "ip.https.enable" "on" | ||
! U1 do "device.reset" "" | ||
|
||
This might be done with a command like: | ||
|
||
cat your_cert_file.zpl > /dev/usb/lp1 | ||
|
||
Once everything is setup, the new printing option should be available eg. in the stock module to print serial numbers | ||
with the option `Serial Number (Send to ZPL-Printer)`. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/report-print-send/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 <https://github.com/OCA/report-print-send/issues/new?body=module:%20zpl_printer%0Aversion:%2016.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 | ||
~~~~~~~ | ||
|
||
* Voltfang GmbH | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Thomas Kosel <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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/report-print-send <https://github.com/OCA/report-print-send/tree/16.0/zpl_printer>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import controllers | ||
from . import model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "ZPL Printer Management", | ||
"version": "16.0.0.0.1", | ||
"category": "Manufacturing", | ||
"summary": "Allows easy management of ZPL-Printers, connects to printers through their URL", | ||
"author": "Voltfang GmbH, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/report-print-send", | ||
"license": "AGPL-3", | ||
"depends": ["base_setup"], | ||
"data": ["security/ir.model.access.csv", "views/zpl_printer_view.xml"], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"zpl_printer/static/src/js/zplactionmanager.esm.js", | ||
] | ||
}, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import json | ||
import logging | ||
|
||
from werkzeug.urls import url_parse | ||
|
||
from odoo import http | ||
from odoo.http import content_disposition, request | ||
from odoo.tools.misc import html_escape | ||
from odoo.tools.safe_eval import safe_eval, time | ||
|
||
from odoo.addons.web.controllers.report import ReportController | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class ReportController(ReportController): | ||
"""Changing report controller to have zpl reports export as .zpl | ||
(and later on be processed to directly print to a zebra printer) | ||
""" | ||
|
||
@http.route(["/report/download"], type="http", auth="user", cors="*") | ||
def report_download(self, data, context=None, token=None): | ||
"""This function is used by 'zplactionmanager.js' in order to trigger | ||
the download of a zpl report. | ||
:param data: a javascript array JSON.stringified containg report | ||
internal url ([0]) and type [1] | ||
:returns: Response with a filetoken cookie and an attachment header | ||
""" | ||
requestcontent = json.loads(data) | ||
url, report_type, resolution = ( | ||
requestcontent[0], | ||
requestcontent[1], | ||
requestcontent[2], | ||
) | ||
if "zpl" not in report_type: | ||
return super().report_download(data, context=context, token=token) | ||
try: | ||
reportname = url.split("/report/zpl/")[1].split("?")[0] | ||
docids = None | ||
if "/" in reportname: | ||
reportname, docids = reportname.split("/") | ||
|
||
if docids: | ||
# Generic report: | ||
response = self.report_routes( | ||
reportname, | ||
docids=docids, | ||
context=json.dumps({"resolution": resolution}), | ||
converter="text", | ||
) | ||
else: | ||
# Particular report: | ||
# decoding the args represented in JSON | ||
data = url_parse(url).decode_query(cls=dict) | ||
if "context" in data: | ||
context, data_context = json.loads(context or "{}"), json.loads( | ||
data.pop("context") | ||
) | ||
context = json.dumps( | ||
{**context, **data_context, "resolution": resolution} | ||
) | ||
response = self.report_routes( | ||
reportname, converter="text", context=context, **data | ||
) | ||
|
||
report = request.env["ir.actions.report"]._get_report_from_name(reportname) | ||
filename = "%s.zpl" % (report.name) | ||
|
||
if docids: | ||
ids = [int(x) for x in docids.split(",") if x.isdigit()] | ||
obj = request.env[report.model].browse(ids) | ||
if report.print_report_name and not len(obj) > 1: | ||
report_name = safe_eval( | ||
report.print_report_name, {"object": obj, "time": time} | ||
) | ||
filename = "%s.zpl" % (report_name) | ||
response.headers.add("Content-Disposition", content_disposition(filename)) | ||
return response | ||
except Exception as e: | ||
se = http.serialize_exception(e) | ||
error = {"code": 200, "message": "Odoo Server Error", "data": se} | ||
return request.make_response(html_escape(json.dumps(error))) | ||
Oops, something went wrong.