From 64218c01e625aeb07be5fa64925db31b213e6a4b Mon Sep 17 00:00:00 2001 From: Christopher Hansen Date: Thu, 9 Jun 2022 13:51:46 +0200 Subject: [PATCH 01/14] Add Module base_report_to_label_printer --- base_report_to_label_printer/README.rst | 73 +++ base_report_to_label_printer/__init__.py | 3 + base_report_to_label_printer/__manifest__.py | 19 + .../models/__init__.py | 4 + .../models/ir_actions_report.py | 15 + .../models/res_users.py | 18 + .../readme/DESCRIPTION.rst | 6 + .../static/description/index.html | 417 ++++++++++++++++++ .../tests/__init__.py | 3 + .../tests/test_ir_actions_report.py | 42 ++ .../views/ir_actions_report.xml | 12 + .../views/res_users.xml | 25 ++ 12 files changed, 637 insertions(+) create mode 100644 base_report_to_label_printer/README.rst create mode 100644 base_report_to_label_printer/__init__.py create mode 100644 base_report_to_label_printer/__manifest__.py create mode 100644 base_report_to_label_printer/models/__init__.py create mode 100644 base_report_to_label_printer/models/ir_actions_report.py create mode 100644 base_report_to_label_printer/models/res_users.py create mode 100644 base_report_to_label_printer/readme/DESCRIPTION.rst create mode 100644 base_report_to_label_printer/static/description/index.html create mode 100644 base_report_to_label_printer/tests/__init__.py create mode 100644 base_report_to_label_printer/tests/test_ir_actions_report.py create mode 100644 base_report_to_label_printer/views/ir_actions_report.xml create mode 100644 base_report_to_label_printer/views/res_users.xml diff --git a/base_report_to_label_printer/README.rst b/base_report_to_label_printer/README.rst new file mode 100644 index 00000000000..d3b116356f2 --- /dev/null +++ b/base_report_to_label_printer/README.rst @@ -0,0 +1,73 @@ +======================= +Report to label printer +======================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-OCA%2Freport--print--send-lightgray.png?logo=github + :target: https://github.com/OCA/report-print-send/tree/14.0/base_report_to_label_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-14-0/report-print-send-14-0-base_report_to_label_printer + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/144/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module makes it possible to print specific reports to a label printer that is configured on the user. + +To do this, the following must be configured: + +* Flag the report as a label report +* Define a label printer for the user + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Raumschmiede GmbH - Christopher Hansen + +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/base_report_to_label_printer/__init__.py b/base_report_to_label_printer/__init__.py new file mode 100644 index 00000000000..69f7babdfb1 --- /dev/null +++ b/base_report_to_label_printer/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/base_report_to_label_printer/__manifest__.py b/base_report_to_label_printer/__manifest__.py new file mode 100644 index 00000000000..ae7ca35b240 --- /dev/null +++ b/base_report_to_label_printer/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright (C) 2022 Raumschmiede GmbH - Christopher Hansen () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Report to label printer", + "version": "14.0.1.0.0", + "category": "Generic Modules/Base", + "author": "Raumschmiede GmbH - Christopher Hansen," + " Odoo Community Association (OCA)", + "website": "https://github.com/OCA/report-print-send", + "license": "AGPL-3", + "depends": ["base_report_to_printer"], + "data": [ + "views/res_users.xml", + "views/ir_actions_report.xml", + ], + "installable": True, + "application": False, +} diff --git a/base_report_to_label_printer/models/__init__.py b/base_report_to_label_printer/models/__init__.py new file mode 100644 index 00000000000..8e2d51b8441 --- /dev/null +++ b/base_report_to_label_printer/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import ir_actions_report +from . import res_users diff --git a/base_report_to_label_printer/models/ir_actions_report.py b/base_report_to_label_printer/models/ir_actions_report.py new file mode 100644 index 00000000000..8a546cc019c --- /dev/null +++ b/base_report_to_label_printer/models/ir_actions_report.py @@ -0,0 +1,15 @@ +# Copyright (C) 2022 Raumschmiede GmbH - Christopher Hansen () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class IrActionsReport(models.Model): + _inherit = "ir.actions.report" + + label = fields.Boolean(string="Report is a Label") + + def _get_user_default_printer(self, user): + if self.label: + return user.default_label_printer_id + return super()._get_user_default_printer(user) diff --git a/base_report_to_label_printer/models/res_users.py b/base_report_to_label_printer/models/res_users.py new file mode 100644 index 00000000000..705b28434d8 --- /dev/null +++ b/base_report_to_label_printer/models/res_users.py @@ -0,0 +1,18 @@ +# Copyright (C) 2022 Raumschmiede GmbH - Christopher Hansen () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ResUsers(models.Model): + _inherit = "res.users" + + default_label_printer_id = fields.Many2one( + comodel_name="printing.printer", string="Default Label Printer" + ) + + @api.model + def _register_hook(self): + super()._register_hook() + self.SELF_WRITEABLE_FIELDS.extend(["default_label_printer_id"]) + self.SELF_READABLE_FIELDS.extend(["default_label_printer_id"]) diff --git a/base_report_to_label_printer/readme/DESCRIPTION.rst b/base_report_to_label_printer/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..5b4738843b2 --- /dev/null +++ b/base_report_to_label_printer/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module makes it possible to print specific reports to a label printer that is configured on the user. + +To do this, the following must be configured: + +* Flag the report as a label report +* Define a label printer for the user diff --git a/base_report_to_label_printer/static/description/index.html b/base_report_to_label_printer/static/description/index.html new file mode 100644 index 00000000000..f62bde7ce94 --- /dev/null +++ b/base_report_to_label_printer/static/description/index.html @@ -0,0 +1,417 @@ + + + + + + +Report to label printer + + + +
+

Report to label printer

+ + +

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

+

This module makes it possible to print specific reports to a label printer that is configured on the user.

+

To do this, the following must be configured:

+
    +
  • Flag the report as a label report
  • +
  • Define a label printer for the user
  • +
+

Table of contents

+ +
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Raumschmiede GmbH - Christopher Hansen
  • +
+
+
+

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/base_report_to_label_printer/tests/__init__.py b/base_report_to_label_printer/tests/__init__.py new file mode 100644 index 00000000000..8eefc7d83d4 --- /dev/null +++ b/base_report_to_label_printer/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_ir_actions_report diff --git a/base_report_to_label_printer/tests/test_ir_actions_report.py b/base_report_to_label_printer/tests/test_ir_actions_report.py new file mode 100644 index 00000000000..07cbca021de --- /dev/null +++ b/base_report_to_label_printer/tests/test_ir_actions_report.py @@ -0,0 +1,42 @@ +# Copyright (C) 2022 Raumschmiede GmbH - Christopher Hansen () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestIrActionsReport(TransactionCase): + def setUp(self): + super(TestIrActionsReport, self).setUp() + self.Model = self.env["ir.actions.report"] + + self.server = self.env["printing.server"].create({}) + + def new_printer(self): + return self.env["printing.printer"].create( + { + "name": "Printer", + "server_id": self.server.id, + "system_name": "Sys Name", + "default": True, + "status": "unknown", + "status_message": "Msg", + "model": "res.users", + "location": "Location", + "uri": "URI", + } + ) + + def test_print_behavior_user_label_printer(self): + """It should return the label printer from user""" + report = self.Model.search([], limit=1) + report.label = True + self.env.user.printing_action = "client" + self.env.user.default_label_printer_id = self.new_printer() + self.assertEqual( + report.behaviour(), + { + "action": "client", + "printer": self.env.user.default_label_printer_id, + "tray": False, + }, + ) diff --git a/base_report_to_label_printer/views/ir_actions_report.xml b/base_report_to_label_printer/views/ir_actions_report.xml new file mode 100644 index 00000000000..0d6b321e985 --- /dev/null +++ b/base_report_to_label_printer/views/ir_actions_report.xml @@ -0,0 +1,12 @@ + + + ir.actions.report.inherit.view.form + ir.actions.report + + + + + + + + diff --git a/base_report_to_label_printer/views/res_users.xml b/base_report_to_label_printer/views/res_users.xml new file mode 100644 index 00000000000..262ea59cf02 --- /dev/null +++ b/base_report_to_label_printer/views/res_users.xml @@ -0,0 +1,25 @@ + + + res.users.inherit.view.form + res.users + + + + + + + + + res.users.inherit.view.form + res.users + + + + + + + + From 533201a61aad170cf3a5d7a3880d94508cc5ba0a Mon Sep 17 00:00:00 2001 From: oca-ci Date: Wed, 21 Dec 2022 10:32:37 +0000 Subject: [PATCH 02/14] [UPD] Update base_report_to_label_printer.pot --- .../i18n/base_report_to_label_printer.pot | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 base_report_to_label_printer/i18n/base_report_to_label_printer.pot diff --git a/base_report_to_label_printer/i18n/base_report_to_label_printer.pot b/base_report_to_label_printer/i18n/base_report_to_label_printer.pot new file mode 100644 index 00000000000..52d9086370b --- /dev/null +++ b/base_report_to_label_printer/i18n/base_report_to_label_printer.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_report_to_label_printer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \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: base_report_to_label_printer +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_res_users__default_label_printer_id +msgid "Default Label Printer" +msgstr "" + +#. module: base_report_to_label_printer +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_ir_actions_report__display_name +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_res_users__display_name +msgid "Display Name" +msgstr "" + +#. module: base_report_to_label_printer +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_ir_actions_report__id +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_res_users__id +msgid "ID" +msgstr "" + +#. module: base_report_to_label_printer +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_ir_actions_report____last_update +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_res_users____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_report_to_label_printer +#: model:ir.model,name:base_report_to_label_printer.model_ir_actions_report +msgid "Report Action" +msgstr "" + +#. module: base_report_to_label_printer +#: model:ir.model.fields,field_description:base_report_to_label_printer.field_ir_actions_report__label +msgid "Report is a Label" +msgstr "" + +#. module: base_report_to_label_printer +#: model:ir.model,name:base_report_to_label_printer.model_res_users +msgid "Users" +msgstr "" From 7f8a0d4cd89139b1dc3c5066abba9a2f7da6c57a Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 21 Dec 2022 10:34:45 +0000 Subject: [PATCH 03/14] [UPD] README.rst --- base_report_to_label_printer/static/description/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_report_to_label_printer/static/description/index.html b/base_report_to_label_printer/static/description/index.html index f62bde7ce94..20622aa4709 100644 --- a/base_report_to_label_printer/static/description/index.html +++ b/base_report_to_label_printer/static/description/index.html @@ -3,7 +3,7 @@ - + Report to label printer