diff --git a/sale_tier_validation_block_print/README.rst b/sale_tier_validation_block_print/README.rst new file mode 100644 index 00000000..a5d317fc --- /dev/null +++ b/sale_tier_validation_block_print/README.rst @@ -0,0 +1,71 @@ +================================ +Sale Tier Validation Block Print +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:93f994da8ba477fc42f77d47b5bf5137fd41397954b1bfba2dc760dbcbb4c664 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/16.0/sale_tier_validation_block_print + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_tier_validation_block_print + :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/sale-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module blocks the printing of the sale order report if the order is not yet approved. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Quartile + +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/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_tier_validation_block_print/__init__.py b/sale_tier_validation_block_print/__init__.py new file mode 100644 index 00000000..65323532 --- /dev/null +++ b/sale_tier_validation_block_print/__init__.py @@ -0,0 +1 @@ +from . import reports diff --git a/sale_tier_validation_block_print/__manifest__.py b/sale_tier_validation_block_print/__manifest__.py new file mode 100644 index 00000000..f1925aa4 --- /dev/null +++ b/sale_tier_validation_block_print/__manifest__.py @@ -0,0 +1,12 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Sale Tier Validation Block Print", + "version": "16.0.1.0.0", + "category": "Sale", + "website": "https://github.com/OCA/sale-workflow", + "author": "Quartile, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["sale_tier_validation"], +} diff --git a/sale_tier_validation_block_print/readme/DESCRIPTION.rst b/sale_tier_validation_block_print/readme/DESCRIPTION.rst new file mode 100644 index 00000000..0238bcb8 --- /dev/null +++ b/sale_tier_validation_block_print/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module blocks the printing of the sale order report if the order is not yet approved. diff --git a/sale_tier_validation_block_print/reports/__init__.py b/sale_tier_validation_block_print/reports/__init__.py new file mode 100644 index 00000000..cd23411b --- /dev/null +++ b/sale_tier_validation_block_print/reports/__init__.py @@ -0,0 +1 @@ +from . import sale_report diff --git a/sale_tier_validation_block_print/reports/sale_report.py b/sale_tier_validation_block_print/reports/sale_report.py new file mode 100644 index 00000000..628a4356 --- /dev/null +++ b/sale_tier_validation_block_print/reports/sale_report.py @@ -0,0 +1,25 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, models +from odoo.exceptions import ValidationError + + +class ReportSaleOrder(models.AbstractModel): + _name = "report.sale.report_saleorder" + _description = "Sale Order Report" + + @api.model + def _get_report_values(self, docids, data=None): + docs = self.env["sale.order"].browse(docids) + for order in docs: + if order.need_validation or (order.review_ids and not order.validated): + raise ValidationError( + _("Quotation printing is blocked until the order is approved.") + ) + return { + "doc_ids": docids, + "doc_model": "sale.order", + "docs": docs, + "data": data, + } diff --git a/sale_tier_validation_block_print/static/description/index.html b/sale_tier_validation_block_print/static/description/index.html new file mode 100644 index 00000000..bc3b5434 --- /dev/null +++ b/sale_tier_validation_block_print/static/description/index.html @@ -0,0 +1,413 @@ + + + + + +Sale Tier Validation Block Print + + + +
+

Sale Tier Validation Block Print

+ + +

Beta License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

This module blocks the printing of the sale order report if the order is not yet approved.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Quartile
  • +
+
+
+

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/sale-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/sale_tier_validation_block_print/tests/__init__.py b/sale_tier_validation_block_print/tests/__init__.py new file mode 100644 index 00000000..f3b3bd7b --- /dev/null +++ b/sale_tier_validation_block_print/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_tier_validation_block_print diff --git a/sale_tier_validation_block_print/tests/test_sale_tier_validation_block_print.py b/sale_tier_validation_block_print/tests/test_sale_tier_validation_block_print.py new file mode 100644 index 00000000..e1b9a357 --- /dev/null +++ b/sale_tier_validation_block_print/tests/test_sale_tier_validation_block_print.py @@ -0,0 +1,44 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.exceptions import ValidationError +from odoo.tests import tagged + +from odoo.addons.sale_tier_validation.tests.test_tier_validation import ( + TestSaleTierValidation, +) + + +@tagged("post_install", "-at_install") +class TestSaleTierValidationBlockPrint(TestSaleTierValidation): + def test_block_print_unvalidated_sale_order(self): + so = self.env["sale.order"].create( + { + "partner_id": self.customer.id, + "order_line": [ + ( + 0, + 0, + { + "name": "Test line", + "product_id": self.product.id, + "product_uom_qty": 1, + "product_uom": self.product.uom_id.id, + "price_unit": self.product.list_price, + }, + ) + ], + "pricelist_id": self.customer.property_product_pricelist.id, + } + ) + + report = self.env["report.sale.report_saleorder"] + # Attempt to render the report before validation + with self.assertRaises(ValidationError): + report._get_report_values(docids=[so.id]) + so.request_validation() + with self.assertRaises(ValidationError): + report._get_report_values(docids=[so.id]) + so.with_user(self.test_user_1).validate_tier() + # Attempt to render the report after validation + report._get_report_values(docids=[so.id]) diff --git a/setup/sale_tier_validation_block_print/odoo/addons/sale_tier_validation_block_print b/setup/sale_tier_validation_block_print/odoo/addons/sale_tier_validation_block_print new file mode 120000 index 00000000..d0634b4f --- /dev/null +++ b/setup/sale_tier_validation_block_print/odoo/addons/sale_tier_validation_block_print @@ -0,0 +1 @@ +../../../../sale_tier_validation_block_print \ No newline at end of file diff --git a/setup/sale_tier_validation_block_print/setup.py b/setup/sale_tier_validation_block_print/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/sale_tier_validation_block_print/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)