From f57d731b6e03ab3afe5cc8e2ca1efa033b3a1d2c Mon Sep 17 00:00:00 2001 From: Marie Lejeune Date: Thu, 13 Nov 2025 16:35:37 +0100 Subject: [PATCH 1/2] [ADD] product_packaging_template_sale: New module Adds the 'Sales' information on packaging template level --- product_packaging_template_sale/README.rst | 81 ++++ product_packaging_template_sale/__init__.py | 1 + .../__manifest__.py | 20 + .../models/__init__.py | 1 + .../models/product_packaging_template.py | 23 + .../pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 1 + .../readme/DESCRIPTION.md | 3 + .../static/description/index.html | 427 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_product_packaging_template.py | 25 + .../views/product_packaging_template.xml | 30 ++ 12 files changed, 616 insertions(+) create mode 100644 product_packaging_template_sale/README.rst create mode 100644 product_packaging_template_sale/__init__.py create mode 100644 product_packaging_template_sale/__manifest__.py create mode 100644 product_packaging_template_sale/models/__init__.py create mode 100644 product_packaging_template_sale/models/product_packaging_template.py create mode 100644 product_packaging_template_sale/pyproject.toml create mode 100644 product_packaging_template_sale/readme/CONTRIBUTORS.md create mode 100644 product_packaging_template_sale/readme/DESCRIPTION.md create mode 100644 product_packaging_template_sale/static/description/index.html create mode 100644 product_packaging_template_sale/tests/__init__.py create mode 100644 product_packaging_template_sale/tests/test_product_packaging_template.py create mode 100644 product_packaging_template_sale/views/product_packaging_template.xml diff --git a/product_packaging_template_sale/README.rst b/product_packaging_template_sale/README.rst new file mode 100644 index 00000000000..a4817a898b5 --- /dev/null +++ b/product_packaging_template_sale/README.rst @@ -0,0 +1,81 @@ +================================ +Product Packaging Template Sales +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4117f24e9fce866ad6bb85f61ac7b8659d84f7874332cfd3153b3f3b5e29b318 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fproduct--attribute-lightgray.png?logo=github + :target: https://github.com/OCA/product-attribute/tree/18.0/product_packaging_template_sale + :alt: OCA/product-attribute +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_packaging_template_sale + :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/product-attribute&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the ``product_packaging_template`` that adds +packaging on template level. + +The goal of this module is being able to set the "Sales" configuration +(determining if a packaging is usable in sale orders) on the packaging +template level. + +**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 +------------ + +- Marie Lejeune + +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/product-attribute `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_packaging_template_sale/__init__.py b/product_packaging_template_sale/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_packaging_template_sale/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_packaging_template_sale/__manifest__.py b/product_packaging_template_sale/__manifest__.py new file mode 100644 index 00000000000..1353b1f4217 --- /dev/null +++ b/product_packaging_template_sale/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Product Packaging Template Sales", + "summary": """Adds the 'Sales' information on packaging template level""", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/product-attribute", + "depends": [ + "product", + "sale", + "product_packaging_template", + ], + "data": [ + "views/product_packaging_template.xml", + ], + "installable": True, +} diff --git a/product_packaging_template_sale/models/__init__.py b/product_packaging_template_sale/models/__init__.py new file mode 100644 index 00000000000..150e5338759 --- /dev/null +++ b/product_packaging_template_sale/models/__init__.py @@ -0,0 +1 @@ +from . import product_packaging_template diff --git a/product_packaging_template_sale/models/product_packaging_template.py b/product_packaging_template_sale/models/product_packaging_template.py new file mode 100644 index 00000000000..ef3e3eedac2 --- /dev/null +++ b/product_packaging_template_sale/models/product_packaging_template.py @@ -0,0 +1,23 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class ProductPackagingTemplate(models.Model): + _inherit = "product.packaging.template" + + sales = fields.Boolean( + default=True, help="If true, the packaging can be used for sales orders" + ) + + @api.model + def _get_values_to_propagate(self, vals): + res = super()._get_values_to_propagate(vals) + if "sales" in vals: + res["sales"] = vals["sales"] + return res + + def _prepare_create_values_for_packaging(self): + res = super()._prepare_create_values_for_packaging() + res["sales"] = self.sales + return res diff --git a/product_packaging_template_sale/pyproject.toml b/product_packaging_template_sale/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/product_packaging_template_sale/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_packaging_template_sale/readme/CONTRIBUTORS.md b/product_packaging_template_sale/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..9b0d5aafb43 --- /dev/null +++ b/product_packaging_template_sale/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Marie Lejeune \<\> diff --git a/product_packaging_template_sale/readme/DESCRIPTION.md b/product_packaging_template_sale/readme/DESCRIPTION.md new file mode 100644 index 00000000000..3466f6a9c5b --- /dev/null +++ b/product_packaging_template_sale/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module extends the `product_packaging_template` that adds packaging on template level. + +The goal of this module is being able to set the "Sales" configuration (determining if a packaging is usable in sale orders) on the packaging template level. diff --git a/product_packaging_template_sale/static/description/index.html b/product_packaging_template_sale/static/description/index.html new file mode 100644 index 00000000000..ca7863573b6 --- /dev/null +++ b/product_packaging_template_sale/static/description/index.html @@ -0,0 +1,427 @@ + + + + + +Product Packaging Template Sales + + + +
+

Product Packaging Template Sales

+ + +

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

+

This module extends the product_packaging_template that adds +packaging on template level.

+

The goal of this module is being able to set the “Sales” configuration +(determining if a packaging is usable in sale orders) on the packaging +template level.

+

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.

+

This module is part of the OCA/product-attribute project on GitHub.

+

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

+
+
+
+ + diff --git a/product_packaging_template_sale/tests/__init__.py b/product_packaging_template_sale/tests/__init__.py new file mode 100644 index 00000000000..a15f23be0e5 --- /dev/null +++ b/product_packaging_template_sale/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_packaging_template diff --git a/product_packaging_template_sale/tests/test_product_packaging_template.py b/product_packaging_template_sale/tests/test_product_packaging_template.py new file mode 100644 index 00000000000..2f7b4a5de4d --- /dev/null +++ b/product_packaging_template_sale/tests/test_product_packaging_template.py @@ -0,0 +1,25 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import Command + +from odoo.addons.product_packaging_template.tests.test_product_packaging_template import ( # noqa: E501 + TestProductPackagingTemplate as BaseTestProductPackagingTemplate, +) + + +class TestProductPackagingTemplate(BaseTestProductPackagingTemplate): + def test_sales_on_packaging_template_default_value(self): + self.template.packaging_tmpl_ids = [ + Command.create({"name": "Box of 10", "qty": 10}) + ] + self.assertTrue(self.variant_1.packaging_ids.sales) + self.assertTrue(self.variant_2.packaging_ids.sales) + self.template.packaging_tmpl_ids.write({"sales": False}) + self.assertFalse(self.variant_1.packaging_ids.sales) + self.assertFalse(self.variant_2.packaging_ids.sales) + self.template.packaging_tmpl_ids.unlink() + self.template.packaging_tmpl_ids = [ + Command.create({"name": "Box of 20", "qty": 20, "sales": False}) + ] + self.assertFalse(self.variant_1.packaging_ids.sales) + self.assertFalse(self.variant_2.packaging_ids.sales) diff --git a/product_packaging_template_sale/views/product_packaging_template.xml b/product_packaging_template_sale/views/product_packaging_template.xml new file mode 100644 index 00000000000..3b1bffe8abf --- /dev/null +++ b/product_packaging_template_sale/views/product_packaging_template.xml @@ -0,0 +1,30 @@ + + + + + product.packaging.template + + + + + + + + + + product.packaging.template + + + + + + + + From d804a0175c1ed7f8ab88970c5b2513e881ae8685 Mon Sep 17 00:00:00 2001 From: Marie Lejeune Date: Thu, 13 Nov 2025 16:37:39 +0100 Subject: [PATCH 2/2] [DONT MERGE] test-requirements.txt --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test-requirements.txt b/test-requirements.txt index 66bc2cbae3f..e47a11752e8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,2 @@ odoo_test_helper +odoo-addon-product-packaging-template @ git+https://github.com/OCA/product-attribute.git@refs/pull/2133/head#subdirectory=product_packaging_template