diff --git a/README.md b/README.md index b21327ea25f..85fb3f3103a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ # report-print-send -TODO: add repo description. +This project aims to deal with the printing of documents on external devices. @@ -19,15 +19,18 @@ TODO: add repo description. Available addons ---------------- -addon | version | maintainers | summary ---- | --- | --- | --- -[base_report_to_label_printer](base_report_to_label_printer/) | 16.0.1.0.0 | | Report to label printer -[base_report_to_printer](base_report_to_printer/) | 16.0.1.1.7 | | Report to printer -[base_report_to_printer_mail](base_report_to_printer_mail/) | 16.0.1.0.0 | | Report to printer - Mail extension +addon | version | maintainers | summary +--- |------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- +[base_report_to_label_printer](base_report_to_label_printer/) | 16.0.1.0.0 | | Report to label printer +[base_report_to_printer](base_report_to_printer/) | 16.0.1.1.7 | | Report to printer +[base_report_to_printer_mail](base_report_to_printer_mail/) | 16.0.1.0.0 | | Report to printer - Mail extension [pingen](pingen/) | 16.0.1.0.1 | [![ajaniszewska-dev](https://github.com/ajaniszewska-dev.png?size=30px)](https://github.com/ajaniszewska-dev) [![grindtildeath](https://github.com/grindtildeath.png?size=30px)](https://github.com/grindtildeath) | pingen.com integration -[pingen_env](pingen_env/) | 16.0.1.0.0 | [![ajaniszewska-dev](https://github.com/ajaniszewska-dev.png?size=30px)](https://github.com/ajaniszewska-dev) | pingen.com server environment -[printer_zpl2](printer_zpl2/) | 16.0.1.0.0 | | Add a ZPL II label printing feature -[printing_simple_configuration](printing_simple_configuration/) | 16.0.1.0.1 | | Allow to set printing configuration in company or in warehouse +[pingen_env](pingen_env/) | 16.0.1.0.0 | [![ajaniszewska-dev](https://github.com/ajaniszewska-dev.png?size=30px)](https://github.com/ajaniszewska-dev) | pingen.com server environment +[printer_zpl2](printer_zpl2/) | 16.0.1.0.0 | | Add a ZPL II label printing feature +[printing_simple_configuration](printing_simple_configuration/) | 16.0.1.0.1 | | Allow to set printing configuration in company or in warehouse +[zpl_printer](zpl_printer/) | 16.0.0.0.1 | [![mohs8421](https://github.com/mohs8421.png?size=30px)](https://github.com/mohs8421) | Directly connect label printers to Odoo +[zpl_printer_mrp](zpl_printer_mrp/) | 16.0.0.0.1 | [![mohs8421](https://github.com/mohs8421.png?size=30px)](https://github.com/mohs8421) | Connects zpl_printer module with mrp module +[zpl_printer_stock](zpl_printer_stock/) | 16.0.0.0.1 | [![mohs8421](https://github.com/mohs8421.png?size=30px)](https://github.com/mohs8421) | Connects zpl_printer module with mrp module, add option to specify printer on product [//]: # (end addons) diff --git a/setup/zpl_printer/odoo/addons/zpl_printer b/setup/zpl_printer/odoo/addons/zpl_printer new file mode 120000 index 00000000000..dfebf246c0d --- /dev/null +++ b/setup/zpl_printer/odoo/addons/zpl_printer @@ -0,0 +1 @@ +../../../../zpl_printer \ No newline at end of file diff --git a/setup/zpl_printer/setup.py b/setup/zpl_printer/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/zpl_printer/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/zpl_printer_mrp/odoo/addons/zpl_printer_mrp b/setup/zpl_printer_mrp/odoo/addons/zpl_printer_mrp new file mode 120000 index 00000000000..5dc813b6342 --- /dev/null +++ b/setup/zpl_printer_mrp/odoo/addons/zpl_printer_mrp @@ -0,0 +1 @@ +../../../../zpl_printer_mrp \ No newline at end of file diff --git a/setup/zpl_printer_mrp/setup.py b/setup/zpl_printer_mrp/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/zpl_printer_mrp/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/zpl_printer_stock/odoo/addons/zpl_printer_stock b/setup/zpl_printer_stock/odoo/addons/zpl_printer_stock new file mode 120000 index 00000000000..aa2d96403f1 --- /dev/null +++ b/setup/zpl_printer_stock/odoo/addons/zpl_printer_stock @@ -0,0 +1 @@ +../../../../zpl_printer_stock \ No newline at end of file diff --git a/setup/zpl_printer_stock/setup.py b/setup/zpl_printer_stock/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/zpl_printer_stock/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/zpl_printer/README.rst b/zpl_printer/README.rst new file mode 100644 index 00000000000..510ea6199fb --- /dev/null +++ b/zpl_printer/README.rst @@ -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 `_. +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 +~~~~~~~ + +* Voltfang GmbH + +Contributors +~~~~~~~~~~~~ + +* Thomas Kosel + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/zpl_printer/__init__.py b/zpl_printer/__init__.py new file mode 100644 index 00000000000..29981cd4b89 --- /dev/null +++ b/zpl_printer/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import model diff --git a/zpl_printer/__manifest__.py b/zpl_printer/__manifest__.py new file mode 100644 index 00000000000..b603fe5e98a --- /dev/null +++ b/zpl_printer/__manifest__.py @@ -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, +} diff --git a/zpl_printer/controllers/__init__.py b/zpl_printer/controllers/__init__.py new file mode 100644 index 00000000000..4c4f242fa03 --- /dev/null +++ b/zpl_printer/controllers/__init__.py @@ -0,0 +1 @@ +from . import report diff --git a/zpl_printer/controllers/report.py b/zpl_printer/controllers/report.py new file mode 100644 index 00000000000..6d2f734d90c --- /dev/null +++ b/zpl_printer/controllers/report.py @@ -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))) diff --git a/zpl_printer/i18n/de.po b/zpl_printer/i18n/de.po new file mode 100644 index 00000000000..3b05d1a74c7 --- /dev/null +++ b/zpl_printer/i18n/de.po @@ -0,0 +1,130 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * zpl_printer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e-20240827\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-08-28 10:41+0000\n" +"PO-Revision-Date: 2024-08-28 10:41+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: zpl_printer +#: model:ir.model.fields.selection,name:zpl_printer.selection__zpl_printer_zpl_printer__resolution__200 +msgid "200" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields.selection,name:zpl_printer.selection__zpl_printer_zpl_printer__resolution__300 +msgid "300" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__create_uid +msgid "Created by" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__create_date +msgid "Created on" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__default +msgid "Default" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__display_name +msgid "Display Name" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__id +msgid "ID" +msgstr "" + +#. module: zpl_printer +#: model:ir.model,name:zpl_printer.model_zpl_printer_zpl_printer +msgid "Label Printer" +msgstr "Label-Drucker" + +#. module: zpl_printer +#: model:ir.actions.act_window,name:zpl_printer.action_zpl_printer +#: model_terms:ir.ui.view,arch_db:zpl_printer.res_config_settings_view_form +msgid "Label-Printers" +msgstr "Label-Drucker" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer____last_update +msgid "Last Modified on" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__write_date +msgid "Last Updated on" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__name +msgid "Name" +msgstr "" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__resolution +msgid "Printing Resolution (DPI)" +msgstr "Auflösung (DPI)" + +#. module: zpl_printer +#: model:ir.model,name:zpl_printer.model_ir_actions_report +msgid "Report Action" +msgstr "Aktion melden" + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_ir_actions_report__report_type +msgid "Report Type" +msgstr "Berichtstyp" + +#. module: zpl_printer +#: model:ir.model.constraint,message:zpl_printer.constraint_zpl_printer_zpl_printer_name_unique +msgid "The name must be unique." +msgstr "Der Name muss eindeutig sein." + +#. module: zpl_printer +#: model:ir.model.fields,help:zpl_printer.field_ir_actions_report__report_type +msgid "" +"The type of the report that will be rendered, each one having its own " +"rendering method. HTML means the report will be opened directly in your " +"browser PDF means the report will be rendered using Wkhtmltopdf and " +"downloaded by the user." +msgstr "" +"Der Typ des Berichts, der gerendert wird, wobei jeder seine eigene " +"Rendering-Methode hat. HTML bedeutet, dass der Bericht direkt in Ihrem " +"Browser geöffnet wird. PDF bedeutet, dass der Bericht mit Wkhtmltopdf " +"gerendert und vom Benutzer heruntergeladen wird." + +#. module: zpl_printer +#: model:ir.model.constraint,message:zpl_printer.constraint_zpl_printer_zpl_printer_url_unique +msgid "The url must be unique." +msgstr "Die URL muss eindeutig sein." + +#. module: zpl_printer +#: model:ir.model.fields,field_description:zpl_printer.field_zpl_printer_zpl_printer__url +msgid "Url" +msgstr "URL" + +#. module: zpl_printer +#: model:ir.model.fields.selection,name:zpl_printer.selection__ir_actions_report__report_type__qweb-zpl +msgid "qweb-zpl" +msgstr "ZPL" diff --git a/zpl_printer/model/__init__.py b/zpl_printer/model/__init__.py new file mode 100644 index 00000000000..7bb715b2520 --- /dev/null +++ b/zpl_printer/model/__init__.py @@ -0,0 +1,2 @@ +from . import ir_actions_report +from . import zpl_printer diff --git a/zpl_printer/model/ir_actions_report.py b/zpl_printer/model/ir_actions_report.py new file mode 100644 index 00000000000..f14bce0d646 --- /dev/null +++ b/zpl_printer/model/ir_actions_report.py @@ -0,0 +1,12 @@ +from odoo import fields, models + + +class IrActionsReport(models.Model): + _inherit = "ir.actions.report" + + report_type = fields.Selection( + selection_add=[("qweb-zpl", "qweb-zpl")], + ondelete={ + "qweb-zpl": "cascade", + }, + ) diff --git a/zpl_printer/model/zpl_printer.py b/zpl_printer/model/zpl_printer.py new file mode 100644 index 00000000000..a1af579b1e3 --- /dev/null +++ b/zpl_printer/model/zpl_printer.py @@ -0,0 +1,41 @@ +from odoo import fields, models + + +class ZplPrinter(models.Model): + _name = "zpl_printer.zpl_printer" + _description = "Label Printer" + _sql_constraints = [ + ( + "name_unique", + "unique(name)", + "The name must be unique.", + ), + ( + "url_unique", + "unique(url)", + "The url must be unique.", + ), + ] + + name = fields.Char() + url = fields.Char() + resolution = fields.Selection( + [("200", "200"), ("300", "300")], "Printing Resolution (DPI)" + ) + default = fields.Boolean() + + def write(self, vals): + """There may only be one default.""" + if vals["default"]: + for previous_default in self.search( + [("default", "=", True), ("id", "!=", self.id)] + ): + previous_default.default = False + return super().write(vals) + + def get_default_printer(self): + return self.search([("default", "=", True)]) + + def get_label_printer_data(self, report_name, active_ids): + default_printer = self.get_default_printer() + return {"url": default_printer.url, "resolution": default_printer.resolution} diff --git a/zpl_printer/readme/CONFIGURE.rst b/zpl_printer/readme/CONFIGURE.rst new file mode 100644 index 00000000000..5d9ad8aa564 --- /dev/null +++ b/zpl_printer/readme/CONFIGURE.rst @@ -0,0 +1,8 @@ +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. diff --git a/zpl_printer/readme/CONTRIBUTORS.rst b/zpl_printer/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..5681a8353fa --- /dev/null +++ b/zpl_printer/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Thomas Kosel diff --git a/zpl_printer/readme/DESCRIPTION.rst b/zpl_printer/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..45f64f4cb8a --- /dev/null +++ b/zpl_printer/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds a new report type for zpl labels, in order to send them directly to a printer through a https request. diff --git a/zpl_printer/readme/USAGE.rst b/zpl_printer/readme/USAGE.rst new file mode 100644 index 00000000000..e1864acea0a --- /dev/null +++ b/zpl_printer/readme/USAGE.rst @@ -0,0 +1,28 @@ +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)`. diff --git a/zpl_printer/security/ir.model.access.csv b/zpl_printer/security/ir.model.access.csv new file mode 100644 index 00000000000..f307082dd22 --- /dev/null +++ b/zpl_printer/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_zpl_printer_zpl_printer_admin,access_zpl_printer_zpl_printer,model_zpl_printer_zpl_printer,base.group_system,1,1,1,1 +access_zpl_printer_zpl_printer_user,access_zpl_printer_zpl_printer,model_zpl_printer_zpl_printer,base.group_user,1,0,0,0 diff --git a/zpl_printer/static/description/index.html b/zpl_printer/static/description/index.html new file mode 100644 index 00000000000..156cd44c7fa --- /dev/null +++ b/zpl_printer/static/description/index.html @@ -0,0 +1,464 @@ + + + + + +ZPL Printer Management + + + +
+

ZPL Printer Management

+ + +

Beta License: AGPL-3 OCA/report-print-send Translate me on Weblate Try me on Runboat

+

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

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to Settings > Integrationen > Label-Printers
  2. +
  3. Add at least one printer as default
  4. +
  5. If using stock or mrp modules, make sure that the connection modules +zrp_printer_mrp / zrp_printer_stock are available.
  6. +
  7. Best used in combination with a further module, that provides layouts for printers, +otherwise default-layouts will be used.
  8. +
+
+
+

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. +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

+
    +
  • Voltfang GmbH
  • +
+
+
+

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/report-print-send project on GitHub.

+

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

+
+
+
+ + diff --git a/zpl_printer/static/src/js/zplactionmanager.esm.js b/zpl_printer/static/src/js/zplactionmanager.esm.js new file mode 100644 index 00000000000..82d9b6742a2 --- /dev/null +++ b/zpl_printer/static/src/js/zplactionmanager.esm.js @@ -0,0 +1,141 @@ +/** @odoo-module **/ + +import {browser} from "@web/core/browser/browser"; +import {makeErrorFromResponse} from "@web/core/network/rpc_service"; +import {registry} from "@web/core/registry"; + +async function print(zpl, url) { + try { + browser.fetch(url, { + method: "POST", + body: zpl, + }); + } catch (e) { + // Generally ignore errors here, as it is probably just a CORS error, that can be ignored, + // if the label has been successfully printed. + console.log(e); + } +} + +async function get_zpl_data(options) { + const xhr = new browser.XMLHttpRequest(); + let data = new FormData(); + if (Object.prototype.hasOwnProperty.call(options, "form")) { + xhr.open(options.form.method, options.form.action); + data = new FormData(options.form); + } else { + xhr.open("POST", options.url); + Object.entries(options.data).forEach((entry) => { + const [key, value] = entry; + data.append(key, value); + }); + } + data.append("token", "dummy-because-api-expects-one"); + if (odoo.csrf_token) { + data.append("csrf_token", odoo.csrf_token); + } + xhr.onload = () => { + // In Odoo, the default mimetype, including for JSON errors is text/html (ref: http.py:Root.get_response ) + // in that case, in order to also be able to download html files, we check if we get a proper filename to be able to download + if (xhr.status === 200) { + if (xhr.response.includes("^XA")) { + print(xhr.response, options.printer_url); + return xhr.response; + } + console.log("Response does not contain zpl data", xhr.response); + } else { + const decoder = new FileReader(); + decoder.onload = () => { + const contents = decoder.result; + const doc = new DOMParser().parseFromString(contents, "text/html"); + const nodes = + doc.body.children.length === 0 + ? doc.body.childNodes + : doc.body.children; + + const error = {}; + try { + // A Serialized python Error + const node = nodes[1] || nodes[0]; + console.log(JSON.parse(node.textContent)); + } catch { + console.log({ + message: "Arbitrary Uncaught Python Exception", + data: { + debug: + `${xhr.status}` + + `\n` + + `${nodes.length > 0 ? nodes[0].textContent : ""} + ${nodes.length > 1 ? nodes[1].textContent : ""}`, + }, + }); + } + console.log(makeErrorFromResponse(error)); + }; + decoder.readAsText(xhr.response); + } + }; + xhr.send(data); +} + +registry + .category("ir.actions.report handlers") + .add("zpl_handler", async function (action, options, env) { + // Zpl reports + if ("report_type" in action && action.report_type === "qweb-zpl") { + let url = `/report/zpl/${action.report_name}`; + const actionContext = action.context || {}; + if ( + _.isUndefined(action.data) || + _.isNull(action.data) || + (_.isObject(action.data) && _.isEmpty(action.data)) + ) { + // Build a query string with `action.data` (it's the place where reports + // using a wizard to customize the output traditionally put their options) + if (actionContext.active_ids) { + var activeIDsPath = "/" + actionContext.active_ids.join(","); + url += activeIDsPath; + } + } else { + var serializedOptionsPath = + "?options=" + encodeURIComponent(JSON.stringify(action.data)); + serializedOptionsPath += + "&context=" + encodeURIComponent(JSON.stringify(actionContext)); + url += serializedOptionsPath; + } + env.services.ui.block(); + try { + const printer_data = await env.services.rpc("/web/dataset/call_kw", { + model: "zpl_printer.zpl_printer", + method: "get_label_printer_data", + args: [[], action.report_name, actionContext.active_ids], + kwargs: {}, + }); + await get_zpl_data({ + url: "/report/download", + data: { + data: JSON.stringify([ + url, + action.report_type, + printer_data.resolution, + ]), + context: JSON.stringify(env.services.user.context), + }, + printer_url: printer_data.url, + }); + } finally { + env.services.ui.unblock(); + } + const onClose = options.onClose; + if (action.close_on_report_download) { + return env.services.action.doAction( + {type: "ir.actions.act_window_close"}, + {onClose} + ); + } else if (onClose) { + onClose(); + } + return Promise.resolve(true); + } + return Promise.resolve(false); + }); diff --git a/zpl_printer/views/zpl_printer_view.xml b/zpl_printer/views/zpl_printer_view.xml new file mode 100644 index 00000000000..83b59c11459 --- /dev/null +++ b/zpl_printer/views/zpl_printer_view.xml @@ -0,0 +1,69 @@ + + + + zpl_printer.zpl_printer.form + zpl_printer.zpl_printer + +
+ +
+

+
+ + + + + + + +
+
+
+
+ + + view.zpl_printer.zpl_printer.tree11 + zpl_printer.zpl_printer + + + + + + + + + + + + Label-Printers + ir.actions.act_window + zpl_printer.zpl_printer + tree,form + + + + res.config.settings.view.form.inherit.zpl_printer + res.config.settings + + + +
+
+
+
+
+
+
+
+
+
diff --git a/zpl_printer_mrp/README.rst b/zpl_printer_mrp/README.rst new file mode 100644 index 00000000000..daebe48eed9 --- /dev/null +++ b/zpl_printer_mrp/README.rst @@ -0,0 +1,83 @@ +=========================================== +ZPL Printer Management (Production related) +=========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ba60804d0f3ce5b766e96f75ce3b27e1765cb42df1b3a7f8f36e07ae7c9fcc52 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_mrp + :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_mrp + :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 connects the zpl_printer module with the mrp module and adds a printing option for +manufacturing orders to print the lot / serial for the producing units. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +In the manufacturing order print serial numbers +with the option `Finished Product Label (Send to ZPL-Printer)`. + +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 +~~~~~~~ + +* Voltfang GmbH + +Contributors +~~~~~~~~~~~~ + +* Thomas Kosel + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/zpl_printer_mrp/__init__.py b/zpl_printer_mrp/__init__.py new file mode 100644 index 00000000000..9186ee3ad24 --- /dev/null +++ b/zpl_printer_mrp/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/zpl_printer_mrp/__manifest__.py b/zpl_printer_mrp/__manifest__.py new file mode 100644 index 00000000000..4d7a41930f8 --- /dev/null +++ b/zpl_printer_mrp/__manifest__.py @@ -0,0 +1,14 @@ +{ + "name": "ZPL Printer Management (Production related)", + "version": "16.0.0.0.1", + "category": "Hidden", + "summary": "Connects ZPL-Printers with Production", + "author": "Voltfang GmbH, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/report-print-send", + "license": "AGPL-3", + "depends": ["zpl_printer", "mrp"], + "data": ["report/mrp_report_views_main.xml"], + "assets": {}, + "installable": True, + "auto_install": True, +} diff --git a/zpl_printer_mrp/i18n/de.po b/zpl_printer_mrp/i18n/de.po new file mode 100644 index 00000000000..0657e9913a9 --- /dev/null +++ b/zpl_printer_mrp/i18n/de.po @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * zpl_printer_mrp +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e-20240827\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-08-29 09:12+0000\n" +"PO-Revision-Date: 2024-08-29 09:12+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: zpl_printer_mrp +#: model:ir.actions.report,name:zpl_printer_mrp.label_manufacture_template +msgid "Finished Product Label (Send to ZPL-Printer)" +msgstr "Produktlabel drucken" + +#. module: zpl_printer_mrp +#: model:ir.model,name:zpl_printer_mrp.model_zpl_printer_zpl_printer +msgid "Label Printer" +msgstr "Label-Drucker" diff --git a/zpl_printer_mrp/model/__init__.py b/zpl_printer_mrp/model/__init__.py new file mode 100644 index 00000000000..ffc95ce3289 --- /dev/null +++ b/zpl_printer_mrp/model/__init__.py @@ -0,0 +1 @@ +from . import zpl_printer diff --git a/zpl_printer_mrp/model/zpl_printer.py b/zpl_printer_mrp/model/zpl_printer.py new file mode 100644 index 00000000000..99f19a3d98d --- /dev/null +++ b/zpl_printer_mrp/model/zpl_printer.py @@ -0,0 +1,13 @@ +from odoo import models + + +class ZplPrinter(models.Model): + _inherit = "zpl_printer.zpl_printer" + + def get_label_printer_data(self, report_name, active_ids): + if report_name == "mrp.label_production_view": + for production in self.env["mrp.production"].browse(active_ids): + if production.product_id.product_tmpl_id.zpl_printer_id: + printer = production.product_id.product_tmpl_id.zpl_printer_id + return {"url": printer.url, "resolution": printer.resolution} + return super().get_label_printer_data(report_name, active_ids) diff --git a/zpl_printer_mrp/readme/CONTRIBUTORS.rst b/zpl_printer_mrp/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..5681a8353fa --- /dev/null +++ b/zpl_printer_mrp/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Thomas Kosel diff --git a/zpl_printer_mrp/readme/DESCRIPTION.rst b/zpl_printer_mrp/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..a8fecbc4a52 --- /dev/null +++ b/zpl_printer_mrp/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module connects the zpl_printer module with the mrp module and adds a printing option for +manufacturing orders to print the lot / serial for the producing units. diff --git a/zpl_printer_mrp/readme/USAGE.rst b/zpl_printer_mrp/readme/USAGE.rst new file mode 100644 index 00000000000..92067616a29 --- /dev/null +++ b/zpl_printer_mrp/readme/USAGE.rst @@ -0,0 +1,2 @@ +In the manufacturing order print serial numbers +with the option `Finished Product Label (Send to ZPL-Printer)`. diff --git a/zpl_printer_mrp/report/mrp_report_views_main.xml b/zpl_printer_mrp/report/mrp_report_views_main.xml new file mode 100644 index 00000000000..59c3da800eb --- /dev/null +++ b/zpl_printer_mrp/report/mrp_report_views_main.xml @@ -0,0 +1,12 @@ + + + + Finished Product Label (Send to ZPL-Printer) + mrp.production + qweb-zpl + mrp.label_production_view + mrp.label_production_view + + report + + diff --git a/zpl_printer_mrp/static/description/index.html b/zpl_printer_mrp/static/description/index.html new file mode 100644 index 00000000000..ad00e687f66 --- /dev/null +++ b/zpl_printer_mrp/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +ZPL Printer Management (Production related) + + + + + + diff --git a/zpl_printer_stock/README.rst b/zpl_printer_stock/README.rst new file mode 100644 index 00000000000..71d255ae190 --- /dev/null +++ b/zpl_printer_stock/README.rst @@ -0,0 +1,87 @@ +====================================== +ZPL Printer Management (Stock related) +====================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5ff36c14f0240e8675cf2d0fdbba6d24411727b7b72d219014d03b060e0835d9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_stock + :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_stock + :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 connects the zpl_printer module with the stock module and adds a printing option +for lot / serial for the producing units. + +Additionally it adds the option to specify a different label printer on the product. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +In the `stock -> lot / serial` view print serial numbers +with the option `Serial Number (Send to ZPL-Printer)`. + +If desired you can specify different printers for different products. + +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 +~~~~~~~ + +* Voltfang GmbH + +Contributors +~~~~~~~~~~~~ + +* Thomas Kosel + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/zpl_printer_stock/__init__.py b/zpl_printer_stock/__init__.py new file mode 100644 index 00000000000..9186ee3ad24 --- /dev/null +++ b/zpl_printer_stock/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/zpl_printer_stock/__manifest__.py b/zpl_printer_stock/__manifest__.py new file mode 100644 index 00000000000..76df3c1d375 --- /dev/null +++ b/zpl_printer_stock/__manifest__.py @@ -0,0 +1,14 @@ +{ + "name": "ZPL Printer Management (Stock related)", + "version": "16.0.0.0.1", + "category": "Hidden", + "summary": "Connects ZPL-Printers with Stock", + "author": "Voltfang GmbH, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/report-print-send", + "license": "AGPL-3", + "depends": ["zpl_printer", "stock"], + "data": ["report/stock_report_views.xml", "views/product_template_view.xml"], + "assets": {}, + "installable": True, + "auto_install": True, +} diff --git a/zpl_printer_stock/i18n/de.po b/zpl_printer_stock/i18n/de.po new file mode 100644 index 00000000000..6e3b3d41651 --- /dev/null +++ b/zpl_printer_stock/i18n/de.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * zpl_printer_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e-20240827\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-08-28 10:42+0000\n" +"PO-Revision-Date: 2024-08-28 10:42+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: zpl_printer_stock +#: model:ir.model,name:zpl_printer_stock.model_zpl_printer_zpl_printer +#: model:ir.model.fields,field_description:zpl_printer_stock.field_product_product__zpl_printer_id +#: model:ir.model.fields,field_description:zpl_printer_stock.field_product_template__zpl_printer_id +msgid "Label Printer" +msgstr "Label-Drucker" + +#. module: zpl_printer_stock +#: model:ir.actions.report,name:zpl_printer_stock.label_picking_type +msgid "Operation type (Send to ZPL-Printer)" +msgstr "Vorgangsart-Label drucken" + +#. module: zpl_printer_stock +#: model:ir.actions.report,name:zpl_printer_stock.label_package_template +msgid "Package Barcode (Send to ZPL-Printer)" +msgstr "Paketetikett drucken" + +#. module: zpl_printer_stock +#: model:ir.model,name:zpl_printer_stock.model_product_template +msgid "Product" +msgstr "Produkt" + +#. module: zpl_printer_stock +#: model:ir.actions.report,name:zpl_printer_stock.label_product_packaging +msgid "Product Packaging (Send to ZPL-Printer)" +msgstr "Product Packaging (Send to ZPL-Printer)" + +#. module: zpl_printer_stock +#: model:ir.actions.report,name:zpl_printer_stock.label_lot_template +msgid "Serial Number (Send to ZPL-Printer)" +msgstr "Seriennummernlabel drucken" diff --git a/zpl_printer_stock/model/__init__.py b/zpl_printer_stock/model/__init__.py new file mode 100644 index 00000000000..3f25a5a4a00 --- /dev/null +++ b/zpl_printer_stock/model/__init__.py @@ -0,0 +1,2 @@ +from . import zpl_printer +from . import product_template diff --git a/zpl_printer_stock/model/product_template.py b/zpl_printer_stock/model/product_template.py new file mode 100644 index 00000000000..2b805a7ffc2 --- /dev/null +++ b/zpl_printer_stock/model/product_template.py @@ -0,0 +1,7 @@ +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + zpl_printer_id = fields.Many2one("zpl_printer.zpl_printer", "Label Printer") diff --git a/zpl_printer_stock/model/zpl_printer.py b/zpl_printer_stock/model/zpl_printer.py new file mode 100644 index 00000000000..82885b5eee1 --- /dev/null +++ b/zpl_printer_stock/model/zpl_printer.py @@ -0,0 +1,13 @@ +from odoo import models + + +class ZplPrinter(models.Model): + _inherit = "zpl_printer.zpl_printer" + + def get_label_printer_data(self, report_name, active_ids): + if report_name == "stock.label_lot_template_view": + for lot in self.env["stock.lot"].browse(active_ids): + if lot.product_id.product_tmpl_id.zpl_printer_id: + printer = lot.product_id.product_tmpl_id.zpl_printer_id + return {"url": printer.url, "resolution": printer.resolution} + return super().get_label_printer_data(report_name, active_ids) diff --git a/zpl_printer_stock/readme/CONTRIBUTORS.rst b/zpl_printer_stock/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..5681a8353fa --- /dev/null +++ b/zpl_printer_stock/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Thomas Kosel diff --git a/zpl_printer_stock/readme/DESCRIPTION.rst b/zpl_printer_stock/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..e1532cb6287 --- /dev/null +++ b/zpl_printer_stock/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module connects the zpl_printer module with the stock module and adds a printing option +for lot / serial for the producing units. + +Additionally it adds the option to specify a different label printer on the product. diff --git a/zpl_printer_stock/readme/USAGE.rst b/zpl_printer_stock/readme/USAGE.rst new file mode 100644 index 00000000000..860ae8fbca1 --- /dev/null +++ b/zpl_printer_stock/readme/USAGE.rst @@ -0,0 +1,4 @@ +In the `stock -> lot / serial` view print serial numbers +with the option `Serial Number (Send to ZPL-Printer)`. + +If desired you can specify different printers for different products. diff --git a/zpl_printer_stock/report/stock_report_views.xml b/zpl_printer_stock/report/stock_report_views.xml new file mode 100644 index 00000000000..03743b33e75 --- /dev/null +++ b/zpl_printer_stock/report/stock_report_views.xml @@ -0,0 +1,39 @@ + + + + Serial Number (Send to ZPL-Printer) + stock.lot + qweb-zpl + stock.label_lot_template_view + stock.label_lot_template_view + + report + + + Package Barcode (Send to ZPL-Printer) + stock.quant.package + qweb-zpl + stock.label_package_template_view + stock.label_package_template_view + + report + + + Product Packaging (Send to ZPL-Printer) + product.packaging + qweb-zpl + stock.label_product_packaging_view + stock.label_product_packaging_view + + report + + + Operation type (Send to ZPL-Printer) + stock.picking.type + qweb-zpl + stock.label_picking_type_view + stock.label_picking_type_view + + report + + diff --git a/zpl_printer_stock/static/description/index.html b/zpl_printer_stock/static/description/index.html new file mode 100644 index 00000000000..c94f16a08e6 --- /dev/null +++ b/zpl_printer_stock/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +ZPL Printer Management (Stock related) + + + + + + diff --git a/zpl_printer_stock/views/product_template_view.xml b/zpl_printer_stock/views/product_template_view.xml new file mode 100644 index 00000000000..dc127d54395 --- /dev/null +++ b/zpl_printer_stock/views/product_template_view.xml @@ -0,0 +1,13 @@ + + + + + product.template.common.form + product.template + + + + + + +