From fdb2477eab11f51e80cc5997d7d4202c2ac84f80 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Fri, 16 Dec 2022 15:22:13 +0100 Subject: [PATCH] fixup! [ADD] stock_picking_auto_print Refactor in base & stock_picking modules --- printing_auto_base/README.rst | 75 ++++ .../__init__.py | 0 printing_auto_base/__manifest__.py | 19 + printing_auto_base/models/__init__.py | 1 + .../models/printing_auto.py | 17 +- .../readme/CONTRIBUTORS.rst | 1 + printing_auto_base/readme/DESCRIPTION.rst | 1 + .../static/description/index.html | 421 ++++++++++++++++++ .../views/printing_auto.xml | 12 +- .../README.rst | 15 +- printing_auto_stock_picking/__init__.py | 1 + .../__manifest__.py | 8 +- .../models/__init__.py | 2 +- .../models/printing_auto.py | 10 + .../models/stock_picking.py | 42 ++ .../models/stock_picking_type.py | 12 + .../readme/CONFIGURE.rst | 0 .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 0 .../security/ir.model.access.csv | 0 .../static/description/index.html | 13 +- .../tests/__init__.py | 0 .../tests/test_printing_auto.py | 12 +- .../views/stock_picking.xml | 32 ++ .../views/stock_picking_type.xml | 13 + .../odoo/addons/printing_auto_base | 1 + .../setup.py | 0 .../odoo/addons/printing_auto_stock_picking | 1 + setup/printing_auto_stock_picking/setup.py | 6 + .../odoo/addons/stock_picking_auto_print | 1 - .../models/stock_picking.py | 16 - .../models/stock_picking_type.py | 18 - .../views/stock_picking_type_views.xml | 13 - 33 files changed, 681 insertions(+), 85 deletions(-) create mode 100644 printing_auto_base/README.rst rename {stock_picking_auto_print => printing_auto_base}/__init__.py (100%) create mode 100644 printing_auto_base/__manifest__.py create mode 100644 printing_auto_base/models/__init__.py rename stock_picking_auto_print/models/stock_auto_printing.py => printing_auto_base/models/printing_auto.py (93%) rename {stock_picking_auto_print => printing_auto_base}/readme/CONTRIBUTORS.rst (88%) create mode 100644 printing_auto_base/readme/DESCRIPTION.rst create mode 100644 printing_auto_base/static/description/index.html rename stock_picking_auto_print/views/stock_auto_printing_views.xml => printing_auto_base/views/printing_auto.xml (83%) rename {stock_picking_auto_print => printing_auto_stock_picking}/README.rst (85%) create mode 100644 printing_auto_stock_picking/__init__.py rename {stock_picking_auto_print => printing_auto_stock_picking}/__manifest__.py (75%) rename {stock_picking_auto_print => printing_auto_stock_picking}/models/__init__.py (64%) create mode 100644 printing_auto_stock_picking/models/printing_auto.py create mode 100644 printing_auto_stock_picking/models/stock_picking.py create mode 100644 printing_auto_stock_picking/models/stock_picking_type.py rename {stock_picking_auto_print => printing_auto_stock_picking}/readme/CONFIGURE.rst (100%) create mode 100644 printing_auto_stock_picking/readme/CONTRIBUTORS.rst rename {stock_picking_auto_print => printing_auto_stock_picking}/readme/DESCRIPTION.rst (100%) rename {stock_picking_auto_print => printing_auto_stock_picking}/security/ir.model.access.csv (100%) rename {stock_picking_auto_print => printing_auto_stock_picking}/static/description/index.html (90%) rename {stock_picking_auto_print => printing_auto_stock_picking}/tests/__init__.py (100%) rename stock_picking_auto_print/tests/test_stock_auto_printing.py => printing_auto_stock_picking/tests/test_printing_auto.py (93%) create mode 100644 printing_auto_stock_picking/views/stock_picking.xml create mode 100644 printing_auto_stock_picking/views/stock_picking_type.xml create mode 120000 setup/printing_auto_base/odoo/addons/printing_auto_base rename setup/{stock_picking_auto_print => printing_auto_base}/setup.py (100%) create mode 120000 setup/printing_auto_stock_picking/odoo/addons/printing_auto_stock_picking create mode 100644 setup/printing_auto_stock_picking/setup.py delete mode 120000 setup/stock_picking_auto_print/odoo/addons/stock_picking_auto_print delete mode 100644 stock_picking_auto_print/models/stock_picking.py delete mode 100644 stock_picking_auto_print/models/stock_picking_type.py delete mode 100644 stock_picking_auto_print/views/stock_picking_type_views.xml diff --git a/printing_auto_base/README.rst b/printing_auto_base/README.rst new file mode 100644 index 00000000000..a283bf11637 --- /dev/null +++ b/printing_auto_base/README.rst @@ -0,0 +1,75 @@ +================== +printing_auto_base +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_base + :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_base + :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 attachements. + +**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 + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux (BCIM) +* 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/stock_picking_auto_print/__init__.py b/printing_auto_base/__init__.py similarity index 100% rename from stock_picking_auto_print/__init__.py rename to printing_auto_base/__init__.py diff --git a/printing_auto_base/__manifest__.py b/printing_auto_base/__manifest__.py new file mode 100644 index 00000000000..c93130ceb1d --- /dev/null +++ b/printing_auto_base/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "application": False, + "author": "BCIM, Odoo Community Association (OCA)", + "category": "Warehouse Management", + "data": [ + "views/printing_auto.xml", + ], + "depends": [ + "base_report_to_printer", + ], + "installable": True, + "license": "AGPL-3", + "name": "printing_auto_base", + "version": "14.0.1.0.0", + "website": "https://github.com/OCA/report-print-send", +} diff --git a/printing_auto_base/models/__init__.py b/printing_auto_base/models/__init__.py new file mode 100644 index 00000000000..ad80a1bfdf6 --- /dev/null +++ b/printing_auto_base/models/__init__.py @@ -0,0 +1 @@ +from . import printing_auto diff --git a/stock_picking_auto_print/models/stock_auto_printing.py b/printing_auto_base/models/printing_auto.py similarity index 93% rename from stock_picking_auto_print/models/stock_auto_printing.py rename to printing_auto_base/models/printing_auto.py index 957bbe99237..902cd9b641b 100644 --- a/stock_picking_auto_print/models/stock_auto_printing.py +++ b/printing_auto_base/models/printing_auto.py @@ -9,9 +9,9 @@ from odoo.tools.safe_eval import safe_eval -class StockAutoPrinting(models.Model): - _name = "stock.auto.printing" - _description = "Stock Auto Printing" +class PrintingAuto(models.Model): + _name = "printing.auto" + _description = "Printing Auto" name = fields.Char(string="Name", required=True) file_type = fields.Selection( @@ -45,7 +45,6 @@ class StockAutoPrinting(models.Model): printer_tray_id = fields.Many2one("printing.tray") nbr_of_copies = fields.Integer("Number of Copies", default=1) - picking_type_id = fields.Many2one("stock.picking.type", required=True) label = fields.Boolean(string="Is Label") @api.constrains("report_id", "file_type") @@ -54,10 +53,8 @@ def check_report(self): if rec.file_type == "report" and not rec.report_id: raise UserError(_("Report was not set")) - def do_automated_printing(self, pickings): + def do_print(self, pickings): self.ensure_one() - if not self.nbr_of_copies: - return behaviour = self.get_behaviour() printer = behaviour["printer"] @@ -66,6 +63,10 @@ def do_automated_printing(self, pickings): _("No printer configured to print this {}.").format(self.name) ) + if self.nbr_of_copies <= 0: + return (printer, 0) + + count = 0 for picking in pickings: if not self._check_condition(picking): continue @@ -73,6 +74,8 @@ def do_automated_printing(self, pickings): for content in self.get_content(record): for _n in range(self.nbr_of_copies): printer.print_document(report=None, content=content, **behaviour) + count += 1 + return (printer, count) def get_behaviour(self): if self.printer_id: diff --git a/stock_picking_auto_print/readme/CONTRIBUTORS.rst b/printing_auto_base/readme/CONTRIBUTORS.rst similarity index 88% rename from stock_picking_auto_print/readme/CONTRIBUTORS.rst rename to printing_auto_base/readme/CONTRIBUTORS.rst index 72acc8c0c7a..c929e955130 100644 --- a/stock_picking_auto_print/readme/CONTRIBUTORS.rst +++ b/printing_auto_base/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Jacques-Etienne Baudoux (BCIM) +* Camptocamp * Christopher Hansen diff --git a/printing_auto_base/readme/DESCRIPTION.rst b/printing_auto_base/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..512693f6afc --- /dev/null +++ b/printing_auto_base/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Base module to support automatic priting of a report or attachements. diff --git a/printing_auto_base/static/description/index.html b/printing_auto_base/static/description/index.html new file mode 100644 index 00000000000..26fee6fb364 --- /dev/null +++ b/printing_auto_base/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +printing_auto_base + + + +
+

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 attachements.

+

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

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/stock_picking_auto_print/views/stock_auto_printing_views.xml b/printing_auto_base/views/printing_auto.xml similarity index 83% rename from stock_picking_auto_print/views/stock_auto_printing_views.xml rename to printing_auto_base/views/printing_auto.xml index e86845aab98..ab3666f5164 100644 --- a/stock_picking_auto_print/views/stock_auto_printing_views.xml +++ b/printing_auto_base/views/printing_auto.xml @@ -1,7 +1,7 @@ - - stock.auto.printing.view.form - stock.auto.printing + + printing.auto.view.form + printing.auto
@@ -34,9 +34,9 @@ - - stock.auto.printing.view.tree - stock.auto.printing + + printing.auto.view.tree + printing.auto diff --git a/stock_picking_auto_print/README.rst b/printing_auto_stock_picking/README.rst similarity index 85% rename from stock_picking_auto_print/README.rst rename to printing_auto_stock_picking/README.rst index fefb5f83b7c..288e56c3804 100644 --- a/stock_picking_auto_print/README.rst +++ b/printing_auto_stock_picking/README.rst @@ -1,6 +1,6 @@ -======================== -stock_picking_auto_print -======================== +=========================== +printing_auto_stock_picking +=========================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! @@ -14,10 +14,10 @@ stock_picking_auto_print :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/stock_picking_auto_print + :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-stock_picking_auto_print + :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 @@ -44,7 +44,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -60,6 +60,7 @@ Contributors ~~~~~~~~~~~~ * Jacques-Etienne Baudoux (BCIM) +* Camptocamp * Christopher Hansen Maintainers @@ -75,6 +76,6 @@ 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. +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/stock_picking_auto_print/__manifest__.py b/printing_auto_stock_picking/__manifest__.py similarity index 75% rename from stock_picking_auto_print/__manifest__.py rename to printing_auto_stock_picking/__manifest__.py index 367e4d2507b..8c3155d24f2 100644 --- a/stock_picking_auto_print/__manifest__.py +++ b/printing_auto_stock_picking/__manifest__.py @@ -7,17 +7,17 @@ "category": "Warehouse Management", "data": [ "security/ir.model.access.csv", - "views/stock_auto_printing_views.xml", - "views/stock_picking_type_views.xml", + "views/stock_picking.xml", + "views/stock_picking_type.xml", ], "demo_xml": [], "depends": [ "stock", - "base_report_to_printer", + "printing_auto_base", ], "installable": True, "license": "AGPL-3", - "name": "stock_picking_auto_print", + "name": "printing_auto_stock_picking", "version": "14.0.1.0.0", "website": "https://github.com/OCA/report-print-send", } diff --git a/stock_picking_auto_print/models/__init__.py b/printing_auto_stock_picking/models/__init__.py similarity index 64% rename from stock_picking_auto_print/models/__init__.py rename to printing_auto_stock_picking/models/__init__.py index dcfe69590d5..a7f544b323e 100644 --- a/stock_picking_auto_print/models/__init__.py +++ b/printing_auto_stock_picking/models/__init__.py @@ -1,3 +1,3 @@ -from . import stock_auto_printing +from . import printing_auto from . import stock_picking from . import stock_picking_type diff --git a/printing_auto_stock_picking/models/printing_auto.py b/printing_auto_stock_picking/models/printing_auto.py new file mode 100644 index 00000000000..ae8222b9a35 --- /dev/null +++ b/printing_auto_stock_picking/models/printing_auto.py @@ -0,0 +1,10 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PrintingAuto(models.Model): + _inherit = "printing.auto" + + picking_type_id = fields.Many2one("stock.picking.type", required=True) 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..a61bf75395c --- /dev/null +++ b/printing_auto_stock_picking/models/stock_picking.py @@ -0,0 +1,42 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging + +from odoo import _, fields, models + +_logger = logging.getLogger(__name__) + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + printing_auto_error = fields.Boolean(string="Printing error") + + def _action_done(self): + result = super()._action_done() + self.send_documents_to_printer() + return result + + def send_documents_to_printer(self): + """Print some report or attachment directly to the corresponding printer.""" + for picking in self: + picking.printing_auto_error = False + if picking.state != "done": + continue + for auto in picking.picking_type_id.auto_printing_ids: + try: + with self.env.cr.savepoint(): + printer, count = auto.do_print(picking) + if count: + self.message_post( + body=_( + "Report {name} sent to printer {printer}" + ).format(name=auto, printer=printer) + ) + except Exception: + _logger.exception( + "An error occurred while printing '%s' for record %s.", + auto, + picking, + ) + picking.printing_auto_error = True 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..641b65a808d --- /dev/null +++ b/printing_auto_stock_picking/models/stock_picking_type.py @@ -0,0 +1,12 @@ +# Copyright 2022 Jacques-Etienne Baudoux (BCIM) +# 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.One2many( + "printing.auto", "picking_type_id", "Auto Printing Configuration" + ) diff --git a/stock_picking_auto_print/readme/CONFIGURE.rst b/printing_auto_stock_picking/readme/CONFIGURE.rst similarity index 100% rename from stock_picking_auto_print/readme/CONFIGURE.rst rename to printing_auto_stock_picking/readme/CONFIGURE.rst diff --git a/printing_auto_stock_picking/readme/CONTRIBUTORS.rst b/printing_auto_stock_picking/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..c929e955130 --- /dev/null +++ b/printing_auto_stock_picking/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Jacques-Etienne Baudoux (BCIM) +* Camptocamp +* Christopher Hansen diff --git a/stock_picking_auto_print/readme/DESCRIPTION.rst b/printing_auto_stock_picking/readme/DESCRIPTION.rst similarity index 100% rename from stock_picking_auto_print/readme/DESCRIPTION.rst rename to printing_auto_stock_picking/readme/DESCRIPTION.rst diff --git a/stock_picking_auto_print/security/ir.model.access.csv b/printing_auto_stock_picking/security/ir.model.access.csv similarity index 100% rename from stock_picking_auto_print/security/ir.model.access.csv rename to printing_auto_stock_picking/security/ir.model.access.csv diff --git a/stock_picking_auto_print/static/description/index.html b/printing_auto_stock_picking/static/description/index.html similarity index 90% rename from stock_picking_auto_print/static/description/index.html rename to printing_auto_stock_picking/static/description/index.html index c335eecb3a9..9baa9ca72b3 100644 --- a/stock_picking_auto_print/static/description/index.html +++ b/printing_auto_stock_picking/static/description/index.html @@ -4,7 +4,7 @@ -stock_picking_auto_print +printing_auto_stock_picking -
-

stock_picking_auto_print

+
+

printing_auto_stock_picking

-

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

+

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

@@ -392,7 +392,7 @@

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.

+feedback.

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

@@ -407,6 +407,7 @@

Authors

Contributors

@@ -417,7 +418,7 @@

Maintainers

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.

+

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/stock_picking_auto_print/tests/__init__.py b/printing_auto_stock_picking/tests/__init__.py similarity index 100% rename from stock_picking_auto_print/tests/__init__.py rename to printing_auto_stock_picking/tests/__init__.py diff --git a/stock_picking_auto_print/tests/test_stock_auto_printing.py b/printing_auto_stock_picking/tests/test_printing_auto.py similarity index 93% rename from stock_picking_auto_print/tests/test_stock_auto_printing.py rename to printing_auto_stock_picking/tests/test_printing_auto.py index 3ec6df285bf..4df51f3609c 100644 --- a/stock_picking_auto_print/tests/test_stock_auto_printing.py +++ b/printing_auto_stock_picking/tests/test_printing_auto.py @@ -26,7 +26,7 @@ def setUpClass(cls): } ) cls.report = cls.env.ref("stock.action_report_delivery") - cls.auto_printing = cls.env["stock.auto.printing"].create( + cls.auto_printing = cls.env["printing.auto"].create( { "name": "Auto Printing 1", "picking_type_id": cls.stock_picking.picking_type_id.id, @@ -34,7 +34,7 @@ def setUpClass(cls): "printer_id": cls.printer_1.id, } ) - cls.auto_printing_2 = cls.env["stock.auto.printing"].create( + cls.auto_printing_2 = cls.env["printing.auto"].create( { "name": "Auto Printing 2", "picking_type_id": cls.stock_picking.picking_type_id.id, @@ -63,15 +63,15 @@ def setUpClass(cls): def test_00_test_general(self): with self.assertRaises(UserError): - self.stock_picking.send_files_to_printer() + self.stock_picking.send_documents_to_printer() def test_10_test_print_report(self): with self.assertRaises(UserError): - self.auto_printing.do_automated_printing(self.stock_picking) + self.auto_printing.do_print(self.stock_picking) def test_20_test_print_attachment(self): with self.assertRaises(UserError): - self.auto_printing_2.do_automated_printing(self.stock_picking) + self.auto_printing_2.do_print(self.stock_picking) def test_30_test_condition_filter(self): self.auto_printing.condition = [("id", "=", self.stock_picking.id)] @@ -103,7 +103,7 @@ def test_50_test_field_object(self): field_object = self.auto_printing._get_record(self.stock_picking) self.assertEqual(field_object, self.stock_picking.picking_type_id) - def test_50_test_printer_and_behavoir(self): + def test_50_test_printer_and_behaviour(self): self.assertEqual( self.auto_printing.get_behaviour()["printer"], self.auto_printing.printer_id, 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..b149bfd4ec2 --- /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/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/stock_picking_auto_print/setup.py b/setup/printing_auto_base/setup.py similarity index 100% rename from setup/stock_picking_auto_print/setup.py rename to setup/printing_auto_base/setup.py 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, +) diff --git a/setup/stock_picking_auto_print/odoo/addons/stock_picking_auto_print b/setup/stock_picking_auto_print/odoo/addons/stock_picking_auto_print deleted file mode 120000 index 4b9e771f46e..00000000000 --- a/setup/stock_picking_auto_print/odoo/addons/stock_picking_auto_print +++ /dev/null @@ -1 +0,0 @@ -../../../../stock_picking_auto_print \ No newline at end of file diff --git a/stock_picking_auto_print/models/stock_picking.py b/stock_picking_auto_print/models/stock_picking.py deleted file mode 100644 index f0d1d301c01..00000000000 --- a/stock_picking_auto_print/models/stock_picking.py +++ /dev/null @@ -1,16 +0,0 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models - - -class StockPicking(models.Model): - _inherit = "stock.picking" - - def _action_done(self): - result = super()._action_done() - self.send_files_to_printer() - return result - - def send_files_to_printer(self): - for rec in self: - rec.picking_type_id.do_automated_printing(rec) diff --git a/stock_picking_auto_print/models/stock_picking_type.py b/stock_picking_auto_print/models/stock_picking_type.py deleted file mode 100644 index 7e15b47e1ff..00000000000 --- a/stock_picking_auto_print/models/stock_picking_type.py +++ /dev/null @@ -1,18 +0,0 @@ -# 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.One2many( - "stock.auto.printing", "picking_type_id", "Auto Printing Configuration" - ) - - def do_automated_printing(self, pickings): - for rec in self: - if not rec.auto_printing_ids: - continue - for auto in rec.auto_printing_ids: - auto.do_automated_printing(pickings) diff --git a/stock_picking_auto_print/views/stock_picking_type_views.xml b/stock_picking_auto_print/views/stock_picking_type_views.xml deleted file mode 100644 index 63f4935afdb..00000000000 --- a/stock_picking_auto_print/views/stock_picking_type_views.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - stock.picking.type.inherit.view.form - stock.picking.type - - - - - - - - -