diff --git a/purchase_packaging_report/README.rst b/purchase_packaging_report/README.rst new file mode 100644 index 00000000..2191ade0 --- /dev/null +++ b/purchase_packaging_report/README.rst @@ -0,0 +1,124 @@ +========================= +Purchase Packaging Report +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8b7207332513658db9206dc6c00893ad62f07ff9132a5cf6947ba271d75ef6cf + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-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_packaging_report + :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_packaging_report + :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 displays packaging data (quantity and type) in: + +- Purchase order printed reports. +- Purchase BI reports. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +#. Go to *Purchase > Configuration > Settings*. #. Enable *Product +Packagings*. #. Save. + +Now, make sure the products you use for testing this module have some +packaging configured. + +Usage +===== + +To print purchase order packaging data: + +#. Go to *Purchase > Orders > Quotations* and pick or create one. #. Add +some product(s) with packaging information (type and quantity). #. Print +it. + +To query purchase packaging BI data: + +#. Go to *Purchase > Reporting > Purchase*. #. Use the new options at +will: + +- *Measures > Packaging Qty* +- *Group By > Packaging*. + +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 +------- + +* Moduon + +Contributors +------------ + +- Eduardo de Miguel (``Moduon ``\ \_\_) + +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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-Shide| image:: https://github.com/Shide.png?size=40px + :target: https://github.com/Shide + :alt: Shide + +Current `maintainer `__: + +|maintainer-Shide| + +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_packaging_report/__init__.py b/purchase_packaging_report/__init__.py new file mode 100644 index 00000000..4c4f242f --- /dev/null +++ b/purchase_packaging_report/__init__.py @@ -0,0 +1 @@ +from . import report diff --git a/purchase_packaging_report/__manifest__.py b/purchase_packaging_report/__manifest__.py new file mode 100644 index 00000000..5bc0f2d1 --- /dev/null +++ b/purchase_packaging_report/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +{ + "name": "Purchase Packaging Report", + "summary": "Packaging data in purchase reports", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "category": "Inventory/Purchase", + "website": "https://github.com/OCA/purchase-reporting", + "author": "Moduon, Odoo Community Association (OCA)", + "maintainers": ["Shide"], + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": [ + "purchase", + ], + "data": [ + "report/purchase_report_views.xml", + "report/purchase_order_templates.xml", + "report/purchase_quotation_templates.xml", + ], +} diff --git a/purchase_packaging_report/i18n/es.po b/purchase_packaging_report/i18n/es.po new file mode 100644 index 00000000..1f9eedb3 --- /dev/null +++ b/purchase_packaging_report/i18n/es.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_packaging_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-05-28 09:54+0000\n" +"PO-Revision-Date: 2024-05-28 11:54+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.4.4\n" + +#. module: purchase_packaging_report +#: model_terms:ir.ui.view,arch_db:purchase_packaging_report.report_purchaseorder_document +#: model_terms:ir.ui.view,arch_db:purchase_packaging_report.report_purchasequotation_document +msgid "(" +msgstr "(" + +#. module: purchase_packaging_report +#: model_terms:ir.ui.view,arch_db:purchase_packaging_report.report_purchaseorder_document +#: model_terms:ir.ui.view,arch_db:purchase_packaging_report.report_purchasequotation_document +msgid ")" +msgstr "" +"Correo electrónico\n" +" *" + +#. module: purchase_packaging_report +#: model:ir.model.fields,field_description:purchase_packaging_report.field_purchase_report__product_packaging_id +msgid "Packaging" +msgstr "Envase" + +#. module: purchase_packaging_report +#: model:ir.model.fields,field_description:purchase_packaging_report.field_purchase_report__product_packaging_qty +msgid "Packaging Qty" +msgstr "Cantidad de Envases" + +#. module: purchase_packaging_report +#: model_terms:ir.ui.view,arch_db:purchase_packaging_report.view_purchase_order_search +msgid "Product Packaging" +msgstr "Envase del Producto" + +#. module: purchase_packaging_report +#: model:ir.model,name:purchase_packaging_report.model_purchase_report +msgid "Purchase Report" +msgstr "Informe de Compras" diff --git a/purchase_packaging_report/i18n/it.po b/purchase_packaging_report/i18n/it.po new file mode 100644 index 00000000..6485f073 --- /dev/null +++ b/purchase_packaging_report/i18n/it.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_packaging_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-06-04 15:39+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 4.17\n" + +#. module: purchase_packaging_report +#: model:ir.model.fields,field_description:purchase_packaging_report.field_purchase_report__product_packaging_id +msgid "Packaging" +msgstr "Imballaggio" + +#. module: purchase_packaging_report +#: model:ir.model.fields,field_description:purchase_packaging_report.field_purchase_report__product_packaging_qty +msgid "Packaging Qty" +msgstr "Q.tà imballagio" + +#. module: purchase_packaging_report +#: model_terms:ir.ui.view,arch_db:purchase_packaging_report.view_purchase_order_search +msgid "Product Packaging" +msgstr "Imballaggio prodotto" + +#. module: purchase_packaging_report +#: model:ir.model,name:purchase_packaging_report.model_purchase_report +msgid "Purchase Report" +msgstr "Resoconto di acquisto" diff --git a/purchase_packaging_report/i18n/purchase_packaging_report.pot b/purchase_packaging_report/i18n/purchase_packaging_report.pot new file mode 100644 index 00000000..235f813d --- /dev/null +++ b/purchase_packaging_report/i18n/purchase_packaging_report.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_packaging_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: purchase_packaging_report +#: model:ir.model.fields,field_description:purchase_packaging_report.field_purchase_report__product_packaging_id +msgid "Packaging" +msgstr "" + +#. module: purchase_packaging_report +#: model:ir.model.fields,field_description:purchase_packaging_report.field_purchase_report__product_packaging_qty +msgid "Packaging Qty" +msgstr "" + +#. module: purchase_packaging_report +#: model_terms:ir.ui.view,arch_db:purchase_packaging_report.view_purchase_order_search +msgid "Product Packaging" +msgstr "" + +#. module: purchase_packaging_report +#: model:ir.model,name:purchase_packaging_report.model_purchase_report +msgid "Purchase Report" +msgstr "" diff --git a/purchase_packaging_report/pyproject.toml b/purchase_packaging_report/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/purchase_packaging_report/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_packaging_report/readme/CONFIGURE.md b/purchase_packaging_report/readme/CONFIGURE.md new file mode 100644 index 00000000..c1c78f15 --- /dev/null +++ b/purchase_packaging_report/readme/CONFIGURE.md @@ -0,0 +1,8 @@ +To configure this module, you need to: + +#. Go to *Purchase > Configuration > Settings*. +#. Enable *Product Packagings*. +#. Save. + +Now, make sure the products you use for testing this module have some packaging +configured. diff --git a/purchase_packaging_report/readme/CONTRIBUTORS.md b/purchase_packaging_report/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..d22e00af --- /dev/null +++ b/purchase_packaging_report/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +* Eduardo de Miguel (`Moduon `__) +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/purchase_packaging_report/readme/DESCRIPTION.md b/purchase_packaging_report/readme/DESCRIPTION.md new file mode 100644 index 00000000..80245d85 --- /dev/null +++ b/purchase_packaging_report/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module displays packaging data (quantity and type) in: + +- Purchase order printed reports. +- Purchase BI reports. diff --git a/purchase_packaging_report/readme/USAGE.md b/purchase_packaging_report/readme/USAGE.md new file mode 100644 index 00000000..1b7ffad9 --- /dev/null +++ b/purchase_packaging_report/readme/USAGE.md @@ -0,0 +1,12 @@ +To print purchase order packaging data: + +#. Go to *Purchase > Orders > Quotations* and pick or create one. +#. Add some product(s) with packaging information (type and quantity). +#. Print it. + +To query purchase packaging BI data: + +#. Go to *Purchase > Reporting > Purchase*. +#. Use the new options at will: + - *Measures > Packaging Qty* + - *Group By > Packaging*. diff --git a/purchase_packaging_report/report/__init__.py b/purchase_packaging_report/report/__init__.py new file mode 100644 index 00000000..84b6eef8 --- /dev/null +++ b/purchase_packaging_report/report/__init__.py @@ -0,0 +1 @@ +from . import purchase_report diff --git a/purchase_packaging_report/report/purchase_order_templates.xml b/purchase_packaging_report/report/purchase_order_templates.xml new file mode 100644 index 00000000..f01ae0cd --- /dev/null +++ b/purchase_packaging_report/report/purchase_order_templates.xml @@ -0,0 +1,19 @@ + + + + diff --git a/purchase_packaging_report/report/purchase_quotation_templates.xml b/purchase_packaging_report/report/purchase_quotation_templates.xml new file mode 100644 index 00000000..52d0fff4 --- /dev/null +++ b/purchase_packaging_report/report/purchase_quotation_templates.xml @@ -0,0 +1,19 @@ + + + + diff --git a/purchase_packaging_report/report/purchase_report.py b/purchase_packaging_report/report/purchase_report.py new file mode 100644 index 00000000..5c8b23ac --- /dev/null +++ b/purchase_packaging_report/report/purchase_report.py @@ -0,0 +1,48 @@ +# Copyright 2023 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + + +from odoo import fields, models +from odoo.tools import SQL + + +class PurchaseReport(models.Model): + _inherit = "purchase.report" + + product_packaging_id = fields.Many2one( + "product.packaging", + string="Packaging", + readonly=True, + ) + product_packaging_qty = fields.Float( + string="Packaging Qty", + readonly=True, + ) + + def _select(self): + return SQL( + """ + %s, + l.product_packaging_id AS product_packaging_id, + SUM(l.product_packaging_qty) AS product_packaging_qty + """, + super()._select(), + ) + + def _from(self): + return SQL( + """ + %s + LEFT JOIN product_packaging ON l.product_packaging_id = product_packaging.id + """, + super()._from(), + ) + + def _group_by(self): + return SQL( + """ + %s, + l.product_packaging_id + """, + super()._group_by(), + ) diff --git a/purchase_packaging_report/report/purchase_report_views.xml b/purchase_packaging_report/report/purchase_report_views.xml new file mode 100644 index 00000000..45989470 --- /dev/null +++ b/purchase_packaging_report/report/purchase_report_views.xml @@ -0,0 +1,41 @@ + + + + purchase.report.view.tree + purchase.report + + + + + + + + + + + report.purchase.order.search + purchase.report + + + + + + + + diff --git a/purchase_packaging_report/static/description/icon.png b/purchase_packaging_report/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/purchase_packaging_report/static/description/icon.png differ diff --git a/purchase_packaging_report/static/description/index.html b/purchase_packaging_report/static/description/index.html new file mode 100644 index 00000000..47262541 --- /dev/null +++ b/purchase_packaging_report/static/description/index.html @@ -0,0 +1,463 @@ + + + + + +Purchase Packaging Report + + + +
+

Purchase Packaging Report

+ + +

Alpha License: LGPL-3 OCA/purchase-reporting Translate me on Weblate Try me on Runboat

+

This module displays packaging data (quantity and type) in:

+
    +
  • Purchase order printed reports.
  • +
  • Purchase BI reports.
  • +
+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+

#. Go to Purchase > Configuration > Settings. #. Enable Product +Packagings. #. Save.

+

Now, make sure the products you use for testing this module have some +packaging configured.

+
+
+

Usage

+

To print purchase order packaging data:

+

#. Go to Purchase > Orders > Quotations and pick or create one. #. Add +some product(s) with packaging information (type and quantity). #. Print +it.

+

To query purchase packaging BI data:

+

#. Go to Purchase > Reporting > Purchase. #. Use the new options at +will:

+
    +
  • Measures > Packaging Qty
  • +
  • Group By > Packaging.
  • +
+
+
+

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

+
    +
  • Moduon
  • +
+
+
+

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:

+

Shide

+

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_packaging_report/tests/__init__.py b/purchase_packaging_report/tests/__init__.py new file mode 100644 index 00000000..c96b9519 --- /dev/null +++ b/purchase_packaging_report/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_packaging_report diff --git a/purchase_packaging_report/tests/test_purchase_packaging_report.py b/purchase_packaging_report/tests/test_purchase_packaging_report.py new file mode 100644 index 00000000..0500f5a6 --- /dev/null +++ b/purchase_packaging_report/tests/test_purchase_packaging_report.py @@ -0,0 +1,61 @@ +# Copyright 2023 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo import Command + +from odoo.addons.base.tests.common import BaseCommon + + +class TestPurchaseReport(BaseCommon): + @classmethod + def setUpClass(self): + super().setUpClass() + self.partner = self.env["res.partner"].create({"name": "Test Vendor"}) + self.product = self.env["product.product"].create( + { + "name": "Test Product", + "type": "consu", + } + ) + self.packaging = self.env["product.packaging"].create( + { + "name": "Box", + "product_id": self.product.id, + "qty": 5, # Packaging contains 5 units + } + ) + self.purchase_order = self.env["purchase.order"].create( + { + "partner_id": self.partner.id, + "order_line": [ + Command.create( + { + "product_id": self.product.id, + "product_qty": 10, + "product_packaging_id": self.packaging.id, + "product_packaging_qty": 10, + } + ) + ], + } + ) + + def test_purchase_report_with_packaging(self): + """Test that purchase.report includes packaging data""" + self.purchase_order.button_confirm() + + purchase_report = self.env["purchase.report"].search( + [("product_id", "=", self.product.id)] + ) + + self.assertTrue(purchase_report, "Purchase report entry was not created") + self.assertEqual( + purchase_report[0].product_packaging_id, + self.packaging, + "Product packaging ID is incorrect in the report", + ) + self.assertEqual( + purchase_report[0].product_packaging_qty, + 10, + "Product packaging quantity is incorrect in the report", + )