diff --git a/base_report_to_label_printer/__manifest__.py b/base_report_to_label_printer/__manifest__.py index ae7ca35b240..b1fdec2b94c 100644 --- a/base_report_to_label_printer/__manifest__.py +++ b/base_report_to_label_printer/__manifest__.py @@ -1,12 +1,11 @@ -# Copyright (C) 2022 Raumschmiede GmbH - Christopher Hansen () +# Copyright 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)", + "author": "Raumschmiede GmbH, Odoo Community Association (OCA)", "website": "https://github.com/OCA/report-print-send", "license": "AGPL-3", "depends": ["base_report_to_printer"], diff --git a/base_report_to_label_printer/models/ir_actions_report.py b/base_report_to_label_printer/models/ir_actions_report.py index 8a546cc019c..e53b7cb72d7 100644 --- a/base_report_to_label_printer/models/ir_actions_report.py +++ b/base_report_to_label_printer/models/ir_actions_report.py @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Raumschmiede GmbH - Christopher Hansen () +# Copyright 2022 Raumschmiede GmbH - Christopher Hansen () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models @@ -7,7 +7,7 @@ class IrActionsReport(models.Model): _inherit = "ir.actions.report" - label = fields.Boolean(string="Report is a Label") + label = fields.Boolean("Report is a Label") def _get_user_default_printer(self, user): if self.label: diff --git a/base_report_to_label_printer/static/description/index.html b/base_report_to_label_printer/static/description/index.html index 20622aa4709..f62bde7ce94 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 + + +
+

printing_auto_base

+ + +

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

+

Base module to support automatic priting of a report or attachments.

+

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

+
    +
  • BCIM
  • +
  • MT Software
  • +
+
+
+

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/printing_auto_base/tests/__init__.py b/printing_auto_base/tests/__init__.py new file mode 100644 index 00000000000..998b91457ce --- /dev/null +++ b/printing_auto_base/tests/__init__.py @@ -0,0 +1 @@ +from . import test_printing_auto_base diff --git a/printing_auto_base/tests/common.py b/printing_auto_base/tests/common.py new file mode 100644 index 00000000000..310d4aff8d8 --- /dev/null +++ b/printing_auto_base/tests/common.py @@ -0,0 +1,96 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# Copyright 2022 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from unittest import mock + +from odoo.tests import common + +from odoo.addons.base_report_to_printer.models.printing_printer import PrintingPrinter + + +def print_document(cls, *args, **kwargs): + return + + +@mock.patch.object(PrintingPrinter, "print_document", print_document) +class TestPrintingAutoCommon(common.SavepointCase): + @classmethod + def _create_printer(cls, name): + return cls.env["printing.printer"].create( + { + "name": name, + "system_name": name, + "server_id": cls.server.id, + } + ) + + @classmethod + def _create_tray(cls, name, printer): + return cls.env["printing.tray"].create( + {"name": name, "system_name": name, "printer_id": printer.id} + ) + + @classmethod + def setUpReportAndRecord(cls): + cls.report = cls.env.ref("base.report_ir_model_overview") + cls.record = cls.env.ref("base.model_res_partner") + + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.server = cls.env["printing.server"].create({}) + for i in range(1, 4): + printer_name = f"printer_{i}" + tray_name = f"tray_{i}" + printer = cls._create_printer(printer_name) + tray = cls._create_tray(tray_name, printer) + setattr(cls, printer_name, printer) + setattr(cls, tray_name, tray) + + cls.setUpReportAndRecord() + cls.data = cls.report._render(cls.record.id)[0] + + @classmethod + def _create_printing_auto(cls, vals): + return cls.env["printing.auto"].create(vals) + + @classmethod + def _create_attachment(cls, record, data, name_suffix): + return cls.env["ir.attachment"].create( + { + "res_model": record._name, + "res_id": record.id, + "name": f"printing_auto_test_attachment_{name_suffix}.txt", + "raw": data, + } + ) + + @classmethod + def _prepare_printing_auto_report_vals(cls): + return { + "data_source": "report", + "report_id": cls.report.id, + "name": "Printing auto report", + } + + @classmethod + def _create_printing_auto_report(cls, vals=None): + _vals = cls._prepare_printing_auto_report_vals() + _vals.update(vals or {}) + return cls._create_printing_auto(_vals) + + @classmethod + def _prepare_printing_auto_attachment_vals(cls): + return { + "data_source": "attachment", + "attachment_domain": "[('name', 'like', 'printing_auto_test_attachment')]", + "name": "Printing auto attachment", + } + + @classmethod + def _create_printing_auto_attachment(cls, vals=None): + _vals = cls._prepare_printing_auto_attachment_vals() + _vals.update(vals or {}) + return cls._create_printing_auto(_vals) diff --git a/printing_auto_base/tests/test_printing_auto_base.py b/printing_auto_base/tests/test_printing_auto_base.py new file mode 100644 index 00000000000..1e1607b49ae --- /dev/null +++ b/printing_auto_base/tests/test_printing_auto_base.py @@ -0,0 +1,92 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# Copyright 2022 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from unittest import mock + +from odoo.exceptions import UserError, ValidationError + +from .common import PrintingPrinter, TestPrintingAutoCommon, print_document + + +@mock.patch.object(PrintingPrinter, "print_document", print_document) +class TestPrintingAutoBase(TestPrintingAutoCommon): + def test_check_data_source(self): + with self.assertRaises(UserError): + self._create_printing_auto_report({"report_id": False}) + + with self.assertRaises(UserError): + self._create_printing_auto_attachment({"attachment_domain": "[]"}) + + with self.assertRaises(UserError): + printing_auto = self._create_printing_auto_attachment() + printing_auto.attachment_domain = False + + def test_behaviour(self): + expected = {"printer": self.printer_1} + printing_auto = self._create_printing_auto_report( + {"printer_id": self.printer_1.id} + ) + self.assertEqual(expected, printing_auto._get_behaviour()) + + printing_auto.printer_tray_id = self.tray_1 + expected["tray"] = self.tray_1.system_name + self.assertEqual(expected, printing_auto._get_behaviour()) + + expected = printing_auto.report_id.behaviour() + printing_auto.printer_id = False + printing_auto.printer_tray_id = False + self.assertEqual(expected, printing_auto._get_behaviour()) + + expected = self.env["ir.actions.report"]._get_user_default_print_behaviour() + printing_auto = self._create_printing_auto_attachment() + self.assertEqual(expected, printing_auto._get_behaviour()) + + def test_record_change(self): + parent = self.env["res.partner"].create({"name": "Parent"}) + partner = parent.create({"name": "Child", "parent_id": parent.id}) + printing_auto = self._create_printing_auto_report( + {"record_change": "parent_id"} + ) + self.assertEqual(parent, printing_auto._get_record(partner)) + + def test_check_condition(self): + partner = self.env["res.partner"].create({"name": "Partner"}) + printing_auto = self._create_printing_auto_report( + {"condition": f"[('name', '=', '{partner.name}')]"} + ) + self.assertEqual(partner, printing_auto._check_condition(partner)) + printing_auto.condition = "[('name', '=', '1')]" + self.assertFalse(printing_auto._check_condition(partner)) + + def test_get_content(self): + printing_auto_report = self._create_printing_auto_report() + self.assertEqual([self.data], printing_auto_report._get_content(self.record)) + + printing_auto_attachment = self._create_printing_auto_attachment() + attachment = self._create_attachment(self.record, self.data, "1") + self.assertEqual( + [attachment.raw], printing_auto_attachment._get_content(self.record) + ) + attachment.unlink() + + with self.assertRaises(ValidationError): + printing_auto_attachment._get_content(self.record) + + def test_do_print(self): + printing_auto = self._create_printing_auto_attachment( + {"attachment_domain": "[('name', 'like', 'printing_auto_test')]"} + ) + self._create_attachment(self.record, self.data, "1") + with self.assertRaises(UserError): + printing_auto.do_print(self.record) + + printing_auto.printer_id = self.printer_1 + for nbr_of_copies in [0, 2, 1]: + expected = (self.printer_1, nbr_of_copies) + printing_auto.nbr_of_copies = nbr_of_copies + self.assertEqual(expected, printing_auto.do_print(self.record)) + + printing_auto.condition = "[('name', '=', 'test_printing_auto')]" + expected = (self.printer_1, 0) + self.assertEqual(expected, printing_auto.do_print(self.record)) diff --git a/printing_auto_base/views/printing_auto.xml b/printing_auto_base/views/printing_auto.xml new file mode 100644 index 00000000000..a346bd5ff35 --- /dev/null +++ b/printing_auto_base/views/printing_auto.xml @@ -0,0 +1,50 @@ + + + printing.auto.view.form + printing.auto + +
+ + + + + + + + + + + + + +
+
+
+ + + printing.auto.view.tree + printing.auto + + + + + + + + + + + + + + +
diff --git a/printing_auto_label_printer/README.rst b/printing_auto_label_printer/README.rst new file mode 100644 index 00000000000..b878cdd1a35 --- /dev/null +++ b/printing_auto_label_printer/README.rst @@ -0,0 +1,77 @@ +=========================== +printing_auto_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/printing_auto_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-printing_auto_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/webui/builds.html?repo=OCA/report-print-send&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Base module to support automatic priting of a report or attachments on a label printer. + +**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 +~~~~~~~ + +* BCIM +* MT Software + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux (BCIM) +* Michael Tietz (MT Software) +* Camptocamp +* 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/printing_auto_label_printer/__init__.py b/printing_auto_label_printer/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/printing_auto_label_printer/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/printing_auto_label_printer/__manifest__.py b/printing_auto_label_printer/__manifest__.py new file mode 100644 index 00000000000..37c16223a53 --- /dev/null +++ b/printing_auto_label_printer/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Printing Auto Label Printer", + "author": "BCIM, MT Software, Odoo Community Association (OCA)", + "category": "Warehouse Management", + "data": [ + "views/printing_auto.xml", + ], + "depends": [ + "base_report_to_label_printer", + "printing_auto_base", + ], + "auto_install": True, + "license": "AGPL-3", + "version": "14.0.1.0.0", + "website": "https://github.com/OCA/report-print-send", +} diff --git a/printing_auto_label_printer/models/__init__.py b/printing_auto_label_printer/models/__init__.py new file mode 100644 index 00000000000..ad80a1bfdf6 --- /dev/null +++ b/printing_auto_label_printer/models/__init__.py @@ -0,0 +1 @@ +from . import printing_auto diff --git a/printing_auto_label_printer/models/printing_auto.py b/printing_auto_label_printer/models/printing_auto.py new file mode 100644 index 00000000000..2c20c972cd2 --- /dev/null +++ b/printing_auto_label_printer/models/printing_auto.py @@ -0,0 +1,16 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# Copyright 2022 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PrintingAuto(models.Model): + _inherit = "printing.auto" + + is_label = fields.Boolean("Is Label") + + def _get_behaviour(self): + if self.is_label and not self.printer_id: + return {"printer": self.env.user.default_label_printer_id} + return super()._get_behaviour() diff --git a/printing_auto_label_printer/readme/CONTRIBUTORS.rst b/printing_auto_label_printer/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..6a130e8ceeb --- /dev/null +++ b/printing_auto_label_printer/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Jacques-Etienne Baudoux (BCIM) +* Michael Tietz (MT Software) +* Camptocamp +* Christopher Hansen diff --git a/printing_auto_label_printer/readme/DESCRIPTION.rst b/printing_auto_label_printer/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..a354dacddb0 --- /dev/null +++ b/printing_auto_label_printer/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Base module to support automatic priting of a report or attachments on a label printer. diff --git a/printing_auto_label_printer/static/description/index.html b/printing_auto_label_printer/static/description/index.html new file mode 100644 index 00000000000..0dc5be5d32a --- /dev/null +++ b/printing_auto_label_printer/static/description/index.html @@ -0,0 +1,423 @@ + + + + + + +printing_auto_label_printer + + + +
+

printing_auto_label_printer

+ + +

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

+

Base module to support automatic priting of a report or attachments on a label printer.

+

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

+
    +
  • BCIM
  • +
  • MT Software
  • +
+
+
+

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/printing_auto_label_printer/tests/__init__.py b/printing_auto_label_printer/tests/__init__.py new file mode 100644 index 00000000000..4bd0e6ae3ec --- /dev/null +++ b/printing_auto_label_printer/tests/__init__.py @@ -0,0 +1 @@ +from . import test_printing_auto_label_printer diff --git a/printing_auto_label_printer/tests/test_printing_auto_label_printer.py b/printing_auto_label_printer/tests/test_printing_auto_label_printer.py new file mode 100644 index 00000000000..19ad06990f6 --- /dev/null +++ b/printing_auto_label_printer/tests/test_printing_auto_label_printer.py @@ -0,0 +1,13 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# Copyright 2022 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.printing_auto_base.tests.common import TestPrintingAutoCommon + + +class TestPrintingAutoBase(TestPrintingAutoCommon): + def test_behaviour_label(self): + self.env.user.default_label_printer_id = self.printer_2 + expected = {"printer": self.printer_2} + printing_auto = self._create_printing_auto_attachment({"is_label": True}) + self.assertEqual(expected, printing_auto._get_behaviour()) diff --git a/printing_auto_label_printer/views/printing_auto.xml b/printing_auto_label_printer/views/printing_auto.xml new file mode 100644 index 00000000000..dca737cb7f4 --- /dev/null +++ b/printing_auto_label_printer/views/printing_auto.xml @@ -0,0 +1,23 @@ + + + printing.auto.label.printer + printing.auto + + + + + + + + + + printing.auto.label.printer + printing.auto + + + + + + + + diff --git a/printing_auto_stock_picking/README.rst b/printing_auto_stock_picking/README.rst new file mode 100644 index 00000000000..dd26b44be3e --- /dev/null +++ b/printing_auto_stock_picking/README.rst @@ -0,0 +1,83 @@ +=========================== +printing_auto_stock_picking +=========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/printing_auto_stock_picking + :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-printing_auto_stock_picking + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/report-print-send&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +When a picking is done, automatically trigger the printing of some documents. +This can be used to print a delivery slip (report) or labels received from the carrier (attachment). + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Go to the Operation Type and configure which report or attachment to print. + +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 +~~~~~~~ + +* BCIM +* MT Software + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux (BCIM) +* Michael Tietz (MT Software) +* Camptocamp +* 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/printing_auto_stock_picking/__init__.py b/printing_auto_stock_picking/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/printing_auto_stock_picking/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/printing_auto_stock_picking/__manifest__.py b/printing_auto_stock_picking/__manifest__.py new file mode 100644 index 00000000000..43ad9ebd1ef --- /dev/null +++ b/printing_auto_stock_picking/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Printing Auto Stock Picking", + "author": "BCIM, MT Software, Odoo Community Association (OCA)", + "category": "Warehouse Management", + "data": [ + "security/ir.model.access.csv", + "views/stock_picking.xml", + "views/stock_picking_type.xml", + ], + "depends": [ + "stock", + "printing_auto_base", + ], + "license": "AGPL-3", + "version": "14.0.1.0.0", + "website": "https://github.com/OCA/report-print-send", +} diff --git a/printing_auto_stock_picking/models/__init__.py b/printing_auto_stock_picking/models/__init__.py new file mode 100644 index 00000000000..dae0bb2efe1 --- /dev/null +++ b/printing_auto_stock_picking/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_picking +from . import stock_picking_type diff --git a/printing_auto_stock_picking/models/stock_picking.py b/printing_auto_stock_picking/models/stock_picking.py new file mode 100644 index 00000000000..500e2b01d03 --- /dev/null +++ b/printing_auto_stock_picking/models/stock_picking.py @@ -0,0 +1,19 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# Copyright 2022 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockPicking(models.Model): + _name = "stock.picking" + _inherit = ["stock.picking", "printing.auto.mixin"] + + auto_printing_ids = fields.Many2many( + "printing.auto", related="picking_type_id.auto_printing_ids" + ) + + def _action_done(self): + result = super()._action_done() + self.handle_print_auto() + return result diff --git a/printing_auto_stock_picking/models/stock_picking_type.py b/printing_auto_stock_picking/models/stock_picking_type.py new file mode 100644 index 00000000000..7ae139fce91 --- /dev/null +++ b/printing_auto_stock_picking/models/stock_picking_type.py @@ -0,0 +1,13 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# Copyright 2022 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockPickingType(models.Model): + _inherit = "stock.picking.type" + + auto_printing_ids = fields.Many2many( + "printing.auto", string="Auto Printing Configuration" + ) diff --git a/printing_auto_stock_picking/readme/CONFIGURE.rst b/printing_auto_stock_picking/readme/CONFIGURE.rst new file mode 100644 index 00000000000..70d33136cea --- /dev/null +++ b/printing_auto_stock_picking/readme/CONFIGURE.rst @@ -0,0 +1 @@ +Go to the Operation Type and configure which report or attachment to print. diff --git a/printing_auto_stock_picking/readme/CONTRIBUTORS.rst b/printing_auto_stock_picking/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..6a130e8ceeb --- /dev/null +++ b/printing_auto_stock_picking/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Jacques-Etienne Baudoux (BCIM) +* Michael Tietz (MT Software) +* Camptocamp +* Christopher Hansen diff --git a/printing_auto_stock_picking/readme/DESCRIPTION.rst b/printing_auto_stock_picking/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..8190ccf510e --- /dev/null +++ b/printing_auto_stock_picking/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +When a picking is done, automatically trigger the printing of some documents. +This can be used to print a delivery slip (report) or labels received from the carrier (attachment). diff --git a/printing_auto_stock_picking/security/ir.model.access.csv b/printing_auto_stock_picking/security/ir.model.access.csv new file mode 100644 index 00000000000..3d90734b967 --- /dev/null +++ b/printing_auto_stock_picking/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_manager,stock_picking_auto_print - manager,printing_auto_base.model_printing_auto,stock.group_stock_manager,1,1,1,1 +access_user,stock_picking_auto_print - user,printing_auto_base.model_printing_auto,stock.group_stock_user,1,0,0,0 diff --git a/printing_auto_stock_picking/static/description/index.html b/printing_auto_stock_picking/static/description/index.html new file mode 100644 index 00000000000..af1c51303c1 --- /dev/null +++ b/printing_auto_stock_picking/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +printing_auto_stock_picking + + + +
+

printing_auto_stock_picking

+ + +

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

+

When a picking is done, automatically trigger the printing of some documents. +This can be used to print a delivery slip (report) or labels received from the carrier (attachment).

+

Table of contents

+ +
+

Configuration

+

Go to the Operation Type and configure which report or attachment to print.

+
+
+

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

+
    +
  • BCIM
  • +
  • MT Software
  • +
+
+
+

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/printing_auto_stock_picking/tests/__init__.py b/printing_auto_stock_picking/tests/__init__.py new file mode 100644 index 00000000000..1a26076862a --- /dev/null +++ b/printing_auto_stock_picking/tests/__init__.py @@ -0,0 +1 @@ +from . import test_printing_auto_stock diff --git a/printing_auto_stock_picking/tests/test_printing_auto_stock.py b/printing_auto_stock_picking/tests/test_printing_auto_stock.py new file mode 100644 index 00000000000..90190196ac8 --- /dev/null +++ b/printing_auto_stock_picking/tests/test_printing_auto_stock.py @@ -0,0 +1,41 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# Copyright 2022 Michael Tietz (MT Software) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging +from unittest import mock + +from odoo.addons.printing_auto_base.tests.common import ( + PrintingPrinter, + TestPrintingAutoCommon, + print_document, +) + + +def exception(*args, **kwargs): + return + + +@mock.patch.object(PrintingPrinter, "print_document", print_document) +@mock.patch.object(logging.Logger, "exception", exception) +class TestAutoPrinting(TestPrintingAutoCommon): + @classmethod + def setUpReportAndRecord(cls): + cls.report = cls.env.ref("stock.action_report_delivery") + cls.record = cls.env.ref("stock.outgoing_shipment_main_warehouse") + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.printing_auto = cls._create_printing_auto_attachment() + cls._create_attachment(cls.record, cls.data, "1") + cls.record.picking_type_id.auto_printing_ids |= cls.printing_auto + + def test_action_done_printing_auto(self): + self.printing_auto.printer_id = self.printer_1 + self.record._action_done() + self.assertFalse(self.record.printing_auto_error) + + def test_action_done_printing_error(self): + self.record._action_done() + self.assertTrue(self.record.printing_auto_error) diff --git a/printing_auto_stock_picking/views/stock_picking.xml b/printing_auto_stock_picking/views/stock_picking.xml new file mode 100644 index 00000000000..71ad6c7bdf0 --- /dev/null +++ b/printing_auto_stock_picking/views/stock_picking.xml @@ -0,0 +1,32 @@ + + + + printing.auto.stock.picking + stock.picking + + + +
+ +
+ +
+
+ +
+
+
diff --git a/printing_auto_stock_picking/views/stock_picking_type.xml b/printing_auto_stock_picking/views/stock_picking_type.xml new file mode 100644 index 00000000000..8c2e299322a --- /dev/null +++ b/printing_auto_stock_picking/views/stock_picking_type.xml @@ -0,0 +1,13 @@ + + + printing.auto.stock.picking + stock.picking.type + + + + + + + + + diff --git a/setup/base_report_to_label_printer/odoo/addons/base_report_to_label_printer b/setup/base_report_to_label_printer/odoo/addons/base_report_to_label_printer deleted file mode 120000 index 9733846765b..00000000000 --- a/setup/base_report_to_label_printer/odoo/addons/base_report_to_label_printer +++ /dev/null @@ -1 +0,0 @@ -../../../../base_report_to_label_printer \ No newline at end of file diff --git a/setup/base_report_to_label_printer/odoo/addons/base_report_to_label_printer b/setup/base_report_to_label_printer/odoo/addons/base_report_to_label_printer new file mode 100644 index 00000000000..9733846765b --- /dev/null +++ b/setup/base_report_to_label_printer/odoo/addons/base_report_to_label_printer @@ -0,0 +1 @@ +../../../../base_report_to_label_printer \ No newline at end of file diff --git a/setup/printing_auto_base/odoo/addons/printing_auto_base b/setup/printing_auto_base/odoo/addons/printing_auto_base new file mode 120000 index 00000000000..b17e1789c1a --- /dev/null +++ b/setup/printing_auto_base/odoo/addons/printing_auto_base @@ -0,0 +1 @@ +../../../../printing_auto_base \ No newline at end of file diff --git a/setup/printing_auto_base/setup.py b/setup/printing_auto_base/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/printing_auto_base/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/printing_auto_label_printer/odoo/addons/printing_auto_label_printer b/setup/printing_auto_label_printer/odoo/addons/printing_auto_label_printer new file mode 120000 index 00000000000..391a7dcd082 --- /dev/null +++ b/setup/printing_auto_label_printer/odoo/addons/printing_auto_label_printer @@ -0,0 +1 @@ +../../../../printing_auto_label_printer \ No newline at end of file diff --git a/setup/printing_auto_label_printer/setup.py b/setup/printing_auto_label_printer/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/printing_auto_label_printer/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/printing_auto_stock_picking/odoo/addons/printing_auto_stock_picking b/setup/printing_auto_stock_picking/odoo/addons/printing_auto_stock_picking new file mode 120000 index 00000000000..1cfa9fa69c1 --- /dev/null +++ b/setup/printing_auto_stock_picking/odoo/addons/printing_auto_stock_picking @@ -0,0 +1 @@ +../../../../printing_auto_stock_picking \ No newline at end of file diff --git a/setup/printing_auto_stock_picking/setup.py b/setup/printing_auto_stock_picking/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/printing_auto_stock_picking/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)