diff --git a/setup/stock_storage_category_capacity_name/odoo/addons/stock_storage_category_capacity_name b/setup/stock_storage_category_capacity_name/odoo/addons/stock_storage_category_capacity_name new file mode 120000 index 000000000..7e8c910f8 --- /dev/null +++ b/setup/stock_storage_category_capacity_name/odoo/addons/stock_storage_category_capacity_name @@ -0,0 +1 @@ +../../../../stock_storage_category_capacity_name \ No newline at end of file diff --git a/setup/stock_storage_category_capacity_name/setup.py b/setup/stock_storage_category_capacity_name/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_storage_category_capacity_name/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_storage_category_capacity_name/README.rst b/stock_storage_category_capacity_name/README.rst new file mode 100644 index 000000000..0fd3a80c8 --- /dev/null +++ b/stock_storage_category_capacity_name/README.rst @@ -0,0 +1,74 @@ +==================================== +Stock Storage Category Capacity Name +==================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fstock--logistics--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_storage_category_capacity_name + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_storage_category_capacity_name + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/16.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to enhance the display of Stock Storage Category Capacity +records as in Odoo core, there is no implementation of name display. + +**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 +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Denis Roussel + +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/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_storage_category_capacity_name/__init__.py b/stock_storage_category_capacity_name/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_storage_category_capacity_name/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_storage_category_capacity_name/__manifest__.py b/stock_storage_category_capacity_name/__manifest__.py new file mode 100644 index 000000000..520be9ae0 --- /dev/null +++ b/stock_storage_category_capacity_name/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Storage Category Capacity Name", + "summary": """ + Allows to have a better display name for Stock Storage Category Capacity model""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "depends": ["stock"], +} diff --git a/stock_storage_category_capacity_name/models/__init__.py b/stock_storage_category_capacity_name/models/__init__.py new file mode 100644 index 000000000..55606c88a --- /dev/null +++ b/stock_storage_category_capacity_name/models/__init__.py @@ -0,0 +1 @@ +from . import stock_storage_category_capacity diff --git a/stock_storage_category_capacity_name/models/stock_storage_category_capacity.py b/stock_storage_category_capacity_name/models/stock_storage_category_capacity.py new file mode 100644 index 000000000..7282e8457 --- /dev/null +++ b/stock_storage_category_capacity_name/models/stock_storage_category_capacity.py @@ -0,0 +1,43 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, models + + +class StockStorageCategoryCapacity(models.Model): + + _inherit = "stock.storage.category.capacity" + + def _get_display_name_attributes(self): + """ + Adds the storage capacity attributes to compose the display name + """ + self.ensure_one() + attributes = [] + if self.product_id: + attributes.append(_("Product: ") + self.product_id.name) + if self.package_type_id: + attributes.append(_("Package: ") + self.package_type_id.name) + return attributes + + @api.model + def _compute_display_name_depends(self): + return [ + "storage_category_id.name", + "quantity", + "product_id.name", + "package_type_id.name", + ] + + @api.depends(lambda self: self._compute_display_name_depends()) + def _compute_display_name(self): + for capacity in self: + name = " ".join( + [str(capacity.storage_category_id.name), "x " + str(capacity.quantity)] + ) + attributes = capacity._get_display_name_attributes() + if attributes: + name += " ({attributes_display})".format( + attributes_display=" - ".join(attributes) + ) + capacity.display_name = name diff --git a/stock_storage_category_capacity_name/readme/CONTRIBUTORS.rst b/stock_storage_category_capacity_name/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9179ee4b8 --- /dev/null +++ b/stock_storage_category_capacity_name/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Denis Roussel diff --git a/stock_storage_category_capacity_name/readme/DESCRIPTION.rst b/stock_storage_category_capacity_name/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e7d77e4a3 --- /dev/null +++ b/stock_storage_category_capacity_name/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to enhance the display of Stock Storage Category Capacity +records as in Odoo core, there is no implementation of name display. diff --git a/stock_storage_category_capacity_name/static/description/icon.png b/stock_storage_category_capacity_name/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_storage_category_capacity_name/static/description/icon.png differ diff --git a/stock_storage_category_capacity_name/static/description/index.html b/stock_storage_category_capacity_name/static/description/index.html new file mode 100644 index 000000000..3ae902d8f --- /dev/null +++ b/stock_storage_category_capacity_name/static/description/index.html @@ -0,0 +1,420 @@ + + + + + + +Stock Storage Category Capacity Name + + + +
+

Stock Storage Category Capacity Name

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module allows to enhance the display of Stock Storage Category Capacity +records as in Odoo core, there is no implementation of name display.

+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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/stock-logistics-warehouse project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_storage_category_capacity_name/tests/__init__.py b/stock_storage_category_capacity_name/tests/__init__.py new file mode 100644 index 000000000..435e22673 --- /dev/null +++ b/stock_storage_category_capacity_name/tests/__init__.py @@ -0,0 +1 @@ +from . import test_capacity_name diff --git a/stock_storage_category_capacity_name/tests/test_capacity_name.py b/stock_storage_category_capacity_name/tests/test_capacity_name.py new file mode 100644 index 000000000..ad3514430 --- /dev/null +++ b/stock_storage_category_capacity_name/tests/test_capacity_name.py @@ -0,0 +1,86 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestStockStorageCategoryCapacity(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product = cls.env["product.product"].create( + { + "name": "Product Test", + } + ) + + def test_storage_capacity_display_package(self): + package_type = self.env["stock.package.type"].create( + { + "name": "Super Pallet", + } + ) + stor_category = self.env["stock.storage.category"].create( + { + "name": "Super Storage Category", + "max_weight": 100, + } + ) + stor_capacity = self.env["stock.storage.category.capacity"].create( + { + "storage_category_id": stor_category.id, + "package_type_id": package_type.id, + "quantity": 1, + } + ) + + self.assertEqual( + stor_capacity.display_name, + "Super Storage Category x 1.0 (Package: Super Pallet)", + ) + + def test_storage_capacity_display_product(self): + stor_category = self.env["stock.storage.category"].create( + { + "name": "Super Storage Category", + "max_weight": 100, + } + ) + stor_capacity = self.env["stock.storage.category.capacity"].create( + { + "storage_category_id": stor_category.id, + "product_id": self.product.id, + "quantity": 1, + } + ) + + self.assertEqual( + stor_capacity.display_name, + "Super Storage Category x 1.0 (Product: Product Test)", + ) + + def test_storage_capacity_display_both(self): + package_type = self.env["stock.package.type"].create( + { + "name": "Super Pallet", + } + ) + stor_category = self.env["stock.storage.category"].create( + { + "name": "Super Storage Category", + "max_weight": 100, + } + ) + stor_capacity = self.env["stock.storage.category.capacity"].create( + { + "storage_category_id": stor_category.id, + "product_id": self.product.id, + "package_type_id": package_type.id, + "quantity": 1, + } + ) + + self.assertEqual( + stor_capacity.display_name, + "Super Storage Category x 1.0 (Product: Product Test - Package: Super Pallet)", + )