diff --git a/setup/shopfloor_product_dimension/odoo/addons/shopfloor_product_dimension b/setup/shopfloor_product_dimension/odoo/addons/shopfloor_product_dimension new file mode 120000 index 00000000000..ad8126efe9c --- /dev/null +++ b/setup/shopfloor_product_dimension/odoo/addons/shopfloor_product_dimension @@ -0,0 +1 @@ +../../../../shopfloor_product_dimension \ No newline at end of file diff --git a/setup/shopfloor_product_dimension/setup.py b/setup/shopfloor_product_dimension/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/shopfloor_product_dimension/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shopfloor_product_dimension/README.rst b/shopfloor_product_dimension/README.rst new file mode 100644 index 00000000000..52c173ba24b --- /dev/null +++ b/shopfloor_product_dimension/README.rst @@ -0,0 +1,86 @@ +=========================== +Shopfloor Product Dimension +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bd9c0c12c938dc2817f948ba5cb58846c9b093646650b0a549f06ef9dca491ad + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fwms-lightgray.png?logo=github + :target: https://github.com/OCA/wms/tree/16.0/shopfloor_product_dimension + :alt: OCA/wms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_product_dimension + :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/wms&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to enrich product details available in shopfloor +flows by adding product dimensions (length, height, width, weight, +dimensional uom). + +**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 +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Denis Roussel denis.roussel@acsone.eu + +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-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px + :target: https://github.com/rousseldenis + :alt: rousseldenis + +Current `maintainer `__: + +|maintainer-rousseldenis| + +This module is part of the `OCA/wms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/shopfloor_product_dimension/__init__.py b/shopfloor_product_dimension/__init__.py new file mode 100644 index 00000000000..f5fe63aaf72 --- /dev/null +++ b/shopfloor_product_dimension/__init__.py @@ -0,0 +1 @@ +from . import actions diff --git a/shopfloor_product_dimension/__manifest__.py b/shopfloor_product_dimension/__manifest__.py new file mode 100644 index 00000000000..0580dee9fda --- /dev/null +++ b/shopfloor_product_dimension/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Shopfloor Product Dimension", + "summary": """This module allow to enrich product available details + about its dimension in shopfloor""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/wms", + "maintainers": ["rousseldenis"], + "depends": [ + "shopfloor", + "product_dimension", + ], +} diff --git a/shopfloor_product_dimension/actions/__init__.py b/shopfloor_product_dimension/actions/__init__.py new file mode 100644 index 00000000000..9d12a798a51 --- /dev/null +++ b/shopfloor_product_dimension/actions/__init__.py @@ -0,0 +1,2 @@ +from . import detail +from . import schema_detail diff --git a/shopfloor_product_dimension/actions/detail.py b/shopfloor_product_dimension/actions/detail.py new file mode 100644 index 00000000000..d202f97c4b6 --- /dev/null +++ b/shopfloor_product_dimension/actions/detail.py @@ -0,0 +1,30 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.addons.component.core import Component + + +class DataDetailAction(Component): + _inherit = "shopfloor.data.detail.action" + + @property + def _product_dimension_parser(self): + return [ + "product_length:length", + "product_height:height", + "product_width:width", + "weight", + ( + "dimensional_uom_id:dimension_uom", + self._simple_record_parser() + ["factor", "rounding"], + ), + ( + "weight_uom_id:weight_uom", + self._simple_record_parser() + ["factor", "rounding"], + ), + ] + + def product_detail(self, record, **kw): + data = super().product_detail(record, **kw) + dimensions_data = self._jsonify(record, self._product_dimension_parser) + data.update(dimensions_data) + return data diff --git a/shopfloor_product_dimension/actions/schema_detail.py b/shopfloor_product_dimension/actions/schema_detail.py new file mode 100644 index 00000000000..3ad59390bcc --- /dev/null +++ b/shopfloor_product_dimension/actions/schema_detail.py @@ -0,0 +1,31 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.addons.component.core import Component + + +class ShopfloorSchemaDetailAction(Component): + _inherit = "shopfloor.schema.detail.action" + + def product_detail(self): + schema = super().product_detail() + schema.update( + { + "length": {"type": "float", "nullable": True, "required": False}, + "width": {"type": "float", "nullable": True, "required": False}, + "height": {"type": "float", "nullable": True, "required": False}, + "weight": {"type": "float", "nullable": True, "required": False}, + "dimension_uom": self._schema_dict_of( + self._simple_record( + factor={"required": True, "nullable": True, "type": "float"}, + rounding={"required": True, "nullable": True, "type": "float"}, + ) + ), + "weight_uom": self._schema_dict_of( + self._simple_record( + factor={"required": True, "nullable": True, "type": "float"}, + rounding={"required": True, "nullable": True, "type": "float"}, + ) + ), + } + ) + return schema diff --git a/shopfloor_product_dimension/readme/CONTRIBUTORS.md b/shopfloor_product_dimension/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..c60a45e3b9b --- /dev/null +++ b/shopfloor_product_dimension/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Denis Roussel \ No newline at end of file diff --git a/shopfloor_product_dimension/readme/DESCRIPTION.md b/shopfloor_product_dimension/readme/DESCRIPTION.md new file mode 100644 index 00000000000..ff4e0f5f533 --- /dev/null +++ b/shopfloor_product_dimension/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows to enrich product details available in shopfloor flows by +adding product dimensions (length, height, width, weight, dimensional uom). diff --git a/shopfloor_product_dimension/static/description/icon.png b/shopfloor_product_dimension/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/shopfloor_product_dimension/static/description/icon.png differ diff --git a/shopfloor_product_dimension/static/description/index.html b/shopfloor_product_dimension/static/description/index.html new file mode 100644 index 00000000000..e123afe17f0 --- /dev/null +++ b/shopfloor_product_dimension/static/description/index.html @@ -0,0 +1,427 @@ + + + + + +Shopfloor Product Dimension + + + +
+

Shopfloor Product Dimension

+ + +

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

+

This module allows to enrich product details available in shopfloor +flows by adding product dimensions (length, height, width, weight, +dimensional uom).

+

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

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

+

Current maintainer:

+

rousseldenis

+

This module is part of the OCA/wms project on GitHub.

+

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

+
+
+
+ + diff --git a/shopfloor_product_dimension/tests/__init__.py b/shopfloor_product_dimension/tests/__init__.py new file mode 100644 index 00000000000..da2f5b41749 --- /dev/null +++ b/shopfloor_product_dimension/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_detail diff --git a/shopfloor_product_dimension/tests/test_product_detail.py b/shopfloor_product_dimension/tests/test_product_detail.py new file mode 100644 index 00000000000..40056ac1fe6 --- /dev/null +++ b/shopfloor_product_dimension/tests/test_product_detail.py @@ -0,0 +1,112 @@ +# Copyright 2020 Camptocamp SA (http://www.camptocamp.com) +# Copyright 2025 ACSONE SA/NV (https://acsone.eu) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import base64 +import io + +from PIL import Image + +from odoo.addons.shopfloor.tests.test_actions_data_base import ActionsDataDetailCaseBase + + +def fake_colored_image(color="#4169E1", size=(800, 500)): + with io.BytesIO() as img_file: + Image.new("RGB", size, color).save(img_file, "JPEG") + img_file.seek(0) + return base64.b64encode(img_file.read()) + + +class TestActionsDataDetailCase(ActionsDataDetailCaseBase): + def _expected_product_detail(self, record, **kw): + res = super()._expected_product_detail(record, **kw) + res.update( + { + "length": record.product_length, + "width": record.product_width, + "height": record.product_height, + "weight": record.weight, + "dimension_uom": { + "id": record.dimensional_uom_id.id, + "factor": record.dimensional_uom_id.factor, + "name": record.dimensional_uom_id.name, + "rounding": record.dimensional_uom_id.rounding, + }, + "weight_uom": { + "id": record.weight_uom_id.id, + "factor": record.weight_uom_id.factor, + "name": record.weight_uom_id.name, + "rounding": record.weight_uom_id.rounding, + }, + } + ) + + return res + + def test_product(self): + move_line = self.move_b.move_line_ids + product = move_line.product_id.with_context(location=move_line.location_id.id) + Partner = self.env["res.partner"].sudo() + + vendor_a = Partner.create({"name": "Supplier A"}) + vendor_b = Partner.create({"name": "Supplier B"}) + SupplierInfo = self.env["product.supplierinfo"].sudo() + SupplierInfo.create( + { + "partner_id": vendor_a.id, + "product_id": product.id, + "product_code": "SUPP1", + } + ) + SupplierInfo.create( + { + "partner_id": vendor_b.id, + "product_id": product.id, + "product_code": "SUPP2", + } + ) + product.sudo().write( + { + "product_length": 12.5, + "product_height": 10.1, + "product_width": 3.5, + "weight": 2.6, + } + ) + data = self.data_detail.product_detail(product) + self.assert_schema(self.schema_detail.product_detail(), data) + expected = self._expected_product_detail(product, full=True) + self.assertDictEqual(data, expected) + + def test_product_template(self): + # Check product supplierinfo on template level + move_line = self.move_b.move_line_ids + product = move_line.product_id.with_context(location=move_line.location_id.id) + Partner = self.env["res.partner"].sudo() + manuf = Partner.create({"name": "Manuf 1"}) + product.sudo().write( + { + "image_128": fake_colored_image(size=(128, 128)), + "manufacturer_id": manuf.id, + } + ) + vendor_a = Partner.create({"name": "Supplier A"}) + vendor_b = Partner.create({"name": "Supplier B"}) + SupplierInfo = self.env["product.supplierinfo"].sudo() + SupplierInfo.create( + { + "partner_id": vendor_a.id, + "product_id": product.id, + "product_code": "SUPP1", + } + ) + SupplierInfo.create( + { + "partner_id": vendor_b.id, + "product_id": product.id, + "product_code": "SUPP2", + } + ) + data = self.data_detail.product_detail(product) + self.assert_schema(self.schema_detail.product_detail(), data) + expected = self._expected_product_detail(product, full=True) + self.assertDictEqual(data, expected)