diff --git a/base_report_to_label_printer/README.rst b/base_report_to_label_printer/README.rst new file mode 100644 index 00000000000..8b361e7530d --- /dev/null +++ b/base_report_to_label_printer/README.rst @@ -0,0 +1,91 @@ +======================= +Report to label printer +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4bf684cbc8b3611e4978597bb436aa423426d49b0eb4c55c79d26353343077e9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.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-18-0/report-print-send-18-0-base_report_to_label_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=18.0 + :alt: Try me on Runboat + +|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 to smash 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 + +Contributors +------------ + +- Hughes Damry +- Khoi (Kien Kim) + +Other credits +------------- + +The migration of this module from 16.0 to 18.0 was financially supported +by: + +- Camptocamp. + +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..3e654a674ab --- /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": "18.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/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..b1f3b912417 --- /dev/null +++ b/base_report_to_label_printer/i18n/base_report_to_label_printer.pot @@ -0,0 +1,34 @@ +# 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 16.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,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 "User" +msgstr "" diff --git a/base_report_to_label_printer/i18n/fr.po b/base_report_to_label_printer/i18n/fr.po new file mode 100644 index 00000000000..af12d8db0b7 --- /dev/null +++ b/base_report_to_label_printer/i18n/fr.po @@ -0,0 +1,37 @@ +# 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 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-05 17:00+0000\n" +"PO-Revision-Date: 2023-06-05 17:00+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \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 "Imprimante étiquettes par défaut" + +#. 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 "Le rapport est une étiquette" + +#. module: base_report_to_label_printer +#: model:ir.model,name:base_report_to_label_printer.model_res_users +msgid "User" +msgstr "Utilisateur" diff --git a/base_report_to_label_printer/i18n/it.po b/base_report_to_label_printer/i18n/it.po new file mode 100644 index 00000000000..0dadb48f5af --- /dev/null +++ b/base_report_to_label_printer/i18n/it.po @@ -0,0 +1,37 @@ +# 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 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-13 13:37+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "Stampante etichetta predefinita" + +#. module: base_report_to_label_printer +#: model:ir.model,name:base_report_to_label_printer.model_ir_actions_report +msgid "Report Action" +msgstr "Azione resoconto" + +#. 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 "Il resoconto è una etichetta" + +#. module: base_report_to_label_printer +#: model:ir.model,name:base_report_to_label_printer.model_res_users +msgid "User" +msgstr "Utente" 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..bcbb10d2b5b --- /dev/null +++ b/base_report_to_label_printer/models/res_users.py @@ -0,0 +1,20 @@ +# 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 ResUsers(models.Model): + _inherit = "res.users" + + default_label_printer_id = fields.Many2one( + comodel_name="printing.printer", string="Default Label Printer" + ) + + @property + def SELF_READABLE_FIELDS(self): + return super().SELF_READABLE_FIELDS + ["default_label_printer_id"] + + @property + def SELF_WRITEABLE_FIELDS(self): + return super().SELF_WRITEABLE_FIELDS + ["default_label_printer_id"] diff --git a/base_report_to_label_printer/pyproject.toml b/base_report_to_label_printer/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/base_report_to_label_printer/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_report_to_label_printer/readme/CONTRIBUTORS.md b/base_report_to_label_printer/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..c818afe213d --- /dev/null +++ b/base_report_to_label_printer/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Hughes Damry \<\> +- Khoi (Kien Kim) \<\> diff --git a/base_report_to_label_printer/readme/CREDITS.md b/base_report_to_label_printer/readme/CREDITS.md new file mode 100644 index 00000000000..b5f45af1151 --- /dev/null +++ b/base_report_to_label_printer/readme/CREDITS.md @@ -0,0 +1,3 @@ +The migration of this module from 16.0 to 18.0 was financially supported by: + +- Camptocamp. diff --git a/base_report_to_label_printer/readme/DESCRIPTION.md b/base_report_to_label_printer/readme/DESCRIPTION.md new file mode 100644 index 00000000000..20657f6ae7e --- /dev/null +++ b/base_report_to_label_printer/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +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/icon.png b/base_report_to_label_printer/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/base_report_to_label_printer/static/description/icon.png differ 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..d7873dedc31 --- /dev/null +++ b/base_report_to_label_printer/static/description/index.html @@ -0,0 +1,439 @@ + + + + + +Report to label printer + + + +
+

Report to label printer

+ + +

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

+

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 to smash 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
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 16.0 to 18.0 was financially supported +by:

+
    +
  • Camptocamp.
  • +
+
+
+

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..25bab848590 --- /dev/null +++ b/base_report_to_label_printer/tests/test_ir_actions_report.py @@ -0,0 +1,44 @@ +# 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): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + cls.Model = cls.env["ir.actions.report"] + cls.server = cls.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 + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..f16443dbd9a --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-base_report_to_printer @ git+https://github.com/OCA/report-print-send.git@refs/pull/371/head#subdirectory=base_report_to_printer