diff --git a/printing_auto_stock_picking/README.rst b/printing_auto_stock_picking/README.rst new file mode 100644 index 000000000..a7d960d99 --- /dev/null +++ b/printing_auto_stock_picking/README.rst @@ -0,0 +1,100 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=========================== +Printing Auto Stock Picking +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:595d25b00b70a3eef28d0dab8e1143977b75e1cd8642f7db586375c45a236a7e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.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-19-0/stock-logistics-reporting-19-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=19.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..c6d4b197d --- /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": "19.0.1.0.0", + "website": "https://github.com/OCA/stock-logistics-reporting", +} diff --git a/printing_auto_stock_picking/i18n/it.po b/printing_auto_stock_picking/i18n/it.po new file mode 100644 index 000000000..5f5e4f6b0 --- /dev/null +++ b/printing_auto_stock_picking/i18n/it.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * printing_auto_stock_picking +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-07-28 09:25+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 5.10.4\n" + +#. module: printing_auto_stock_picking +#: model:ir.model.fields,field_description:printing_auto_stock_picking.field_stock_picking__auto_printing_ids +#: model:ir.model.fields,field_description:printing_auto_stock_picking.field_stock_picking_type__auto_printing_ids +#: model_terms:ir.ui.view,arch_db:printing_auto_stock_picking.view_picking_type_form_inherit +msgid "Auto Printing Configuration" +msgstr "Configurazione stampa automatica" + +#. module: printing_auto_stock_picking +#: model:ir.model,name:printing_auto_stock_picking.model_stock_picking_type +msgid "Picking Type" +msgstr "Tipo prelievo" + +#. module: printing_auto_stock_picking +#: model_terms:ir.ui.view,arch_db:printing_auto_stock_picking.view_picking_form +msgid "Print documents" +msgstr "Stampa documenti" + +#. module: printing_auto_stock_picking +#: model:ir.model.fields,field_description:printing_auto_stock_picking.field_stock_picking__printing_auto_error +msgid "Printing error" +msgstr "Errore di stampa" + +#. module: printing_auto_stock_picking +#: model:ir.model,name:printing_auto_stock_picking.model_stock_picking +msgid "Transfer" +msgstr "Trasferimento" + +#. module: printing_auto_stock_picking +#: model_terms:ir.ui.view,arch_db:printing_auto_stock_picking.view_picking_form +msgid "" +"Unable to print the documents: the CUPS server is maybe not available, or " +"printers are not configured properly. Error:" +msgstr "" +"Impossibile stampare i documenti: il server CUPS non รจ disponibile o o le " +"stampanti non sono configurate correttamente. Errore:" diff --git a/printing_auto_stock_picking/i18n/printing_auto_stock_picking.pot b/printing_auto_stock_picking/i18n/printing_auto_stock_picking.pot new file mode 100644 index 000000000..f2df52fde --- /dev/null +++ b/printing_auto_stock_picking/i18n/printing_auto_stock_picking.pot @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * printing_auto_stock_picking +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: printing_auto_stock_picking +#: model:ir.model.fields,field_description:printing_auto_stock_picking.field_stock_picking__auto_printing_ids +#: model:ir.model.fields,field_description:printing_auto_stock_picking.field_stock_picking_type__auto_printing_ids +#: model_terms:ir.ui.view,arch_db:printing_auto_stock_picking.view_picking_type_form_inherit +msgid "Auto Printing Configuration" +msgstr "" + +#. module: printing_auto_stock_picking +#: model:ir.model,name:printing_auto_stock_picking.model_stock_picking_type +msgid "Picking Type" +msgstr "" + +#. module: printing_auto_stock_picking +#: model_terms:ir.ui.view,arch_db:printing_auto_stock_picking.view_picking_form +msgid "Print documents" +msgstr "" + +#. module: printing_auto_stock_picking +#: model:ir.model.fields,field_description:printing_auto_stock_picking.field_stock_picking__printing_auto_error +msgid "Printing error" +msgstr "" + +#. module: printing_auto_stock_picking +#: model:ir.model,name:printing_auto_stock_picking.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: printing_auto_stock_picking +#: model_terms:ir.ui.view,arch_db:printing_auto_stock_picking.view_picking_form +msgid "" +"Unable to print the documents: the CUPS server is maybe not available, or " +"printers are not configured properly. Error:" +msgstr "" 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..d58664d24 --- /dev/null +++ b/printing_auto_stock_picking/models/stock_picking_type.py @@ -0,0 +1,14 @@ +# 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/pyproject.toml b/printing_auto_stock_picking/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/printing_auto_stock_picking/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/printing_auto_stock_picking/readme/CONFIGURE.md b/printing_auto_stock_picking/readme/CONFIGURE.md new file mode 100644 index 000000000..3153ccdb4 --- /dev/null +++ b/printing_auto_stock_picking/readme/CONFIGURE.md @@ -0,0 +1,2 @@ +Go to the Operation Type and configure which report or attachment to +print. diff --git a/printing_auto_stock_picking/readme/CONTRIBUTORS.md b/printing_auto_stock_picking/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..e98f3cd2b --- /dev/null +++ b/printing_auto_stock_picking/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Jacques-Etienne Baudoux (BCIM) \<\> +- Michael Tietz (MT Software) \<\> +- Camptocamp +- Christopher Hansen \<\> diff --git a/printing_auto_stock_picking/readme/DESCRIPTION.md b/printing_auto_stock_picking/readme/DESCRIPTION.md new file mode 100644 index 000000000..f0fcbff24 --- /dev/null +++ b/printing_auto_stock_picking/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +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..df2d5722d --- /dev/null +++ b/printing_auto_stock_picking/security/ir_rule.xml @@ -0,0 +1,13 @@ + + + + stock picking auto print + + [("model", "=", "stock.picking")] + + + + + + + diff --git a/printing_auto_stock_picking/static/description/icon.png b/printing_auto_stock_picking/static/description/icon.png new file mode 100644 index 000000000..1dcc49c24 Binary files /dev/null and b/printing_auto_stock_picking/static/description/icon.png differ 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..677b30041 --- /dev/null +++ b/printing_auto_stock_picking/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

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..4f4a95dfa --- /dev/null +++ b/printing_auto_stock_picking/tests/test_printing_auto_stock.py @@ -0,0 +1,68 @@ +# 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.exceptions import UserError +from odoo.tools import mute_logger + +from odoo.addons.printing_auto_base.tests.common import ( + TestPrintingAutoCommon, + patch_print_document, +) + + +@patch_print_document() +class TestAutoPrinting(TestPrintingAutoCommon): + @classmethod + def setUpReportAndRecord(cls): + cls.report_ref = "stock.action_report_delivery" + partner = cls.env["res.partner"].create({"name": "Test partner"}) + product = cls.env["product.product"].create( + {"name": "Test product", "type": "consu"} + ) + cls.record = cls.env["stock.picking"].create( + { + "partner_id": partner.id, + "picking_type_id": cls.env.ref("stock.picking_type_out").id, + "location_id": cls.env.ref("stock.stock_location_stock").id, + "location_dest_id": cls.env.ref("stock.stock_location_customers").id, + "move_ids": [ + ( + 0, + 0, + { + "product_id": product.id, + "product_uom": product.uom_id.id, + "product_uom_qty": 15.0, + "location_id": cls.env.ref("stock.stock_location_stock").id, + "location_dest_id": cls.env.ref( + "stock.stock_location_customers" + ).id, + }, + ) + ], + } + ) + + 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): + with mute_logger("odoo.addons.printing_auto_base.models.printing_auto_mixin"): + 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..7aeaebcf7 --- /dev/null +++ b/printing_auto_stock_picking/views/stock_picking.xml @@ -0,0 +1,30 @@ + + + + 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..4e456405e --- /dev/null +++ b/printing_auto_stock_picking/views/stock_picking_type.xml @@ -0,0 +1,17 @@ + + + printing.auto.stock.picking + stock.picking.type + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..52b89bab2 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,3 @@ +odoo-addon-base_report_to_printer @ git+https://github.com/OCA/report-print-send.git@refs/pull/436/head#subdirectory=base_report_to_printer +odoo-addon-base_report_to_printer_cups @ git+https://github.com/OCA/report-print-send.git@refs/pull/436/head#subdirectory=base_report_to_printer_cups +odoo-addon-printing_auto_base @ git+https://github.com/OCA/report-print-send.git@refs/pull/437/head#subdirectory=printing_auto_base