diff --git a/printing_auto_stock_picking/README.rst b/printing_auto_stock_picking/README.rst new file mode 100644 index 000000000..214811de7 --- /dev/null +++ b/printing_auto_stock_picking/README.rst @@ -0,0 +1,94 @@ +=========================== +Printing Auto Stock Picking +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4710fc372fc2fd7f0e76ac7a85e80d0085d241012504943c41d828f44863809e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fstock--logistics--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-reporting/tree/14.0/printing_auto_stock_picking + :alt: OCA/stock-logistics-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-14-0/stock-logistics-reporting-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/builds?repo=OCA/stock-logistics-reporting&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 to smash 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. + +.. |maintainer-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px + :target: https://github.com/jbaudoux + :alt: jbaudoux + +Current `maintainer `__: + +|maintainer-jbaudoux| + +This module is part of the `OCA/stock-logistics-reporting `_ 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 000000000..0650744f6 --- /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 000000000..484125cea --- /dev/null +++ b/printing_auto_stock_picking/__manifest__.py @@ -0,0 +1,22 @@ +# 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)", + "maintainers": ["jbaudoux"], + "category": "Warehouse Management", + "data": [ + "security/ir.model.access.csv", + "security/ir_rule.xml", + "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/stock-logistics-reporting", +} diff --git a/printing_auto_stock_picking/models/__init__.py b/printing_auto_stock_picking/models/__init__.py new file mode 100644 index 000000000..dae0bb2ef --- /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 000000000..500e2b01d --- /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 000000000..dbca36da7 --- /dev/null +++ b/printing_auto_stock_picking/models/stock_picking_type.py @@ -0,0 +1,15 @@ +# 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", + domain=[("model", "=", "stock.picking.type")], + ) diff --git a/printing_auto_stock_picking/readme/CONFIGURE.rst b/printing_auto_stock_picking/readme/CONFIGURE.rst new file mode 100644 index 000000000..70d33136c --- /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 000000000..6a130e8ce --- /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 000000000..8190ccf51 --- /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 000000000..3d90734b9 --- /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/security/ir_rule.xml b/printing_auto_stock_picking/security/ir_rule.xml new file mode 100644 index 000000000..3ceacbda3 --- /dev/null +++ b/printing_auto_stock_picking/security/ir_rule.xml @@ -0,0 +1,13 @@ + + + + stock picking auto print + + [("model", "=", "stock.picking.type")] + + + + + + + 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 000000000..e7f3f4a35 --- /dev/null +++ b/printing_auto_stock_picking/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +Printing Auto Stock Picking + + + +
+

Printing Auto Stock Picking

+ + +

Beta License: AGPL-3 OCA/stock-logistics-reporting 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 to smash 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.

+

Current maintainer:

+

jbaudoux

+

This module is part of the OCA/stock-logistics-reporting 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 000000000..1a2607686 --- /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 000000000..a6f4f06a8 --- /dev/null +++ b/printing_auto_stock_picking/tests/test_printing_auto_stock.py @@ -0,0 +1,43 @@ +# 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 + +from odoo.addons.printing_auto_base.tests.common import ( + PrintingPrinter, + TestPrintingAutoCommon, + print_document, +) + + +@mock.patch.object(PrintingPrinter, "print_document", print_document) +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") + + def setUp(self): + # Note: Using setUpClass, cls.record.picking_type_id.auto_printing_ids + # is reset on each test making them fail + super().setUp() + self.printing_auto = self._create_printing_auto_attachment() + self._create_attachment(self.record, self.data, "1") + self.record.picking_type_id.auto_printing_ids |= self.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_log(self): + self.record._action_done() + self.assertTrue(self.record.printing_auto_error) + + def test_action_done_printing_error_raise(self): + self.printing_auto.action_on_error = "raise" + with self.assertRaises(UserError): + self.record._action_done() 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 000000000..71ad6c7bd --- /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 000000000..f957549f3 --- /dev/null +++ b/printing_auto_stock_picking/views/stock_picking_type.xml @@ -0,0 +1,16 @@ + + + printing.auto.stock.picking + stock.picking.type + + + + + + + + + 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 000000000..1cfa9fa69 --- /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 000000000..28c57bb64 --- /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, +)