diff --git a/purchase_report_discount_visibility/README.rst b/purchase_report_discount_visibility/README.rst new file mode 100644 index 00000000..1f9e22fe --- /dev/null +++ b/purchase_report_discount_visibility/README.rst @@ -0,0 +1,90 @@ +=================================== +Purchase Report Discount Visibility +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:05dac72a6e6696a83805350b894a8e6e1060336c5cdee57062a239faa1bc4885 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpurchase--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-reporting/tree/18.0/purchase_report_discount_visibility + :alt: OCA/purchase-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-reporting-18-0/purchase-reporting-18-0-purchase_report_discount_visibility + :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/purchase-reporting&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module hides the Discount column in the Purchase Order report if +all order lines have no discount applied. + +**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 + +Contributors +------------ + +- `Quartile `__: + + - Aung Ko Ko Lin + +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-yostashiro| image:: https://github.com/yostashiro.png?size=40px + :target: https://github.com/yostashiro + :alt: yostashiro +.. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px + :target: https://github.com/aungkokolin1997 + :alt: aungkokolin1997 + +Current `maintainers `__: + +|maintainer-yostashiro| |maintainer-aungkokolin1997| + +This module is part of the `OCA/purchase-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_report_discount_visibility/__init__.py b/purchase_report_discount_visibility/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/purchase_report_discount_visibility/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_report_discount_visibility/__manifest__.py b/purchase_report_discount_visibility/__manifest__.py new file mode 100644 index 00000000..d7004b4d --- /dev/null +++ b/purchase_report_discount_visibility/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2026 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Purchase Report Discount Visibility", + "summary": "Configure visibility of discount column in purchase reports", + "version": "18.0.1.0.0", + "category": "Reporting", + "license": "AGPL-3", + "website": "https://github.com/OCA/purchase-reporting", + "author": "Quartile, Odoo Community Association (OCA)", + "depends": ["purchase"], + "data": [ + "report/purchase_report_templates.xml", + ], + "maintainers": ["yostashiro", "aungkokolin1997"], + "installable": True, +} diff --git a/purchase_report_discount_visibility/models/__init__.py b/purchase_report_discount_visibility/models/__init__.py new file mode 100644 index 00000000..9f035306 --- /dev/null +++ b/purchase_report_discount_visibility/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order diff --git a/purchase_report_discount_visibility/models/purchase_order.py b/purchase_report_discount_visibility/models/purchase_order.py new file mode 100644 index 00000000..d205069c --- /dev/null +++ b/purchase_report_discount_visibility/models/purchase_order.py @@ -0,0 +1,12 @@ +# Copyright 2026 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + def _display_discount(self): + self.ensure_one() + return any(line.discount for line in self.order_line) diff --git a/purchase_report_discount_visibility/pyproject.toml b/purchase_report_discount_visibility/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/purchase_report_discount_visibility/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_report_discount_visibility/readme/CONTRIBUTORS.md b/purchase_report_discount_visibility/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..faae3280 --- /dev/null +++ b/purchase_report_discount_visibility/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Quartile](https://www.quartile.co): + - Aung Ko Ko Lin diff --git a/purchase_report_discount_visibility/readme/DESCRIPTION.md b/purchase_report_discount_visibility/readme/DESCRIPTION.md new file mode 100644 index 00000000..f635a62c --- /dev/null +++ b/purchase_report_discount_visibility/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module hides the Discount column in the Purchase Order report if all order lines have +no discount applied. diff --git a/purchase_report_discount_visibility/report/purchase_report_templates.xml b/purchase_report_discount_visibility/report/purchase_report_templates.xml new file mode 100644 index 00000000..d2c42377 --- /dev/null +++ b/purchase_report_discount_visibility/report/purchase_report_templates.xml @@ -0,0 +1,14 @@ + + + + diff --git a/purchase_report_discount_visibility/static/description/index.html b/purchase_report_discount_visibility/static/description/index.html new file mode 100644 index 00000000..9a8f8c65 --- /dev/null +++ b/purchase_report_discount_visibility/static/description/index.html @@ -0,0 +1,429 @@ + + + + + +Purchase Report Discount Visibility + + + +
+

Purchase Report Discount Visibility

+ + +

Beta License: AGPL-3 OCA/purchase-reporting Translate me on Weblate Try me on Runboat

+

This module hides the Discount column in the Purchase Order report if +all order lines have no discount applied.

+

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

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 maintainers:

+

yostashiro aungkokolin1997

+

This module is part of the OCA/purchase-reporting project on GitHub.

+

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

+
+
+
+ + diff --git a/purchase_report_discount_visibility/tests/__init__.py b/purchase_report_discount_visibility/tests/__init__.py new file mode 100644 index 00000000..46bb3796 --- /dev/null +++ b/purchase_report_discount_visibility/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_report_discount_visibility diff --git a/purchase_report_discount_visibility/tests/test_purchase_report_discount_visibility.py b/purchase_report_discount_visibility/tests/test_purchase_report_discount_visibility.py new file mode 100644 index 00000000..0912f80d --- /dev/null +++ b/purchase_report_discount_visibility/tests/test_purchase_report_discount_visibility.py @@ -0,0 +1,39 @@ +# Copyright 2026 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.fields import Command + +from odoo.addons.base.tests.common import BaseCommon + + +class TestPurchaseReportDiscountVisibility(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.vendor = cls.env["res.partner"].create({"name": "Test Vendor"}) + cls.product = cls.env["product.product"].create({"name": "Test Product"}) + + def _create_po(self, discounts): + return self.env["purchase.order"].create( + { + "partner_id": self.vendor.id, + "order_line": [ + Command.create( + { + "name": self.product.name, + "product_id": self.product.id, + "product_qty": 1.0, + "price_unit": 100.0, + "discount": d, + } + ) + for d in discounts + ], + } + ) + + def test_display_discount(self): + po = self._create_po([0.0, 0.0, 0.0]) + self.assertFalse(po._display_discount()) + po = self._create_po([0.0, 10.0, 0.0]) + self.assertTrue(po._display_discount())