diff --git a/uom_category_active/README.rst b/uom_category_active/README.rst new file mode 100644 index 00000000000..377f9dbac72 --- /dev/null +++ b/uom_category_active/README.rst @@ -0,0 +1,94 @@ +=================== +UoM Category Active +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e027b589dfe0610db88cff23371b1f56e707d8186534ec42d10b0e5d0e0843fd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/uom_category_active + :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-uom_category_active + :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 allows you to archive UoM categories. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. Active Unit of Measures on *Inventory > Configuration > Settings + [Products/Units of Measures]* . +2. Go to *Inventory > Configuration > Unit of Measures > UoM + Categories*. +3. Select a UoM category or create a new one. +4. Click on the smart button Archive (this action will set active field + to False). + +Note: If there are UoM in the category to be archived, this UoM will be +archived to. + +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 +------- + +* PESOL + +Contributors +------------ + +- `PESOL `__: + + - Angel Moya + +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/uom_category_active/__init__.py b/uom_category_active/__init__.py new file mode 100644 index 00000000000..4b76c7b2d5c --- /dev/null +++ b/uom_category_active/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/uom_category_active/__manifest__.py b/uom_category_active/__manifest__.py new file mode 100644 index 00000000000..a9c5252c283 --- /dev/null +++ b/uom_category_active/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# Copyright 2023 PESOL - Angel Moya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "UoM Category Active", + "version": "18.0.1.0.0", + "category": "Product", + "summary": "Add option to archive UoM categories", + "author": "PESOL, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/product-attribute", + "license": "AGPL-3", + "depends": ["uom"], + "data": ["views/uom_category_views.xml"], +} diff --git a/uom_category_active/i18n/it.po b/uom_category_active/i18n/it.po new file mode 100644 index 00000000000..79645c60a3f --- /dev/null +++ b/uom_category_active/i18n/it.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * uom_category_active +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-07 09: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: uom_category_active +#: model:ir.model.fields,field_description:uom_category_active.field_uom_category__active +msgid "Active" +msgstr "Attiva" + +#. module: uom_category_active +#: model:ir.model.fields,help:uom_category_active.field_uom_category__active +msgid "" +"If unchecked, it will allow you to hide the product category without " +"removing it." +msgstr "" +"Se non selezionato, consente di nascondere la categoria dei prodotti senza " +"rimuoverla." + +#. module: uom_category_active +#: model:ir.model,name:uom_category_active.model_uom_category +msgid "Product UoM Categories" +msgstr "Categorie UdM prodotto" diff --git a/uom_category_active/i18n/uom_category_active.pot b/uom_category_active/i18n/uom_category_active.pot new file mode 100644 index 00000000000..0c76b5a36b8 --- /dev/null +++ b/uom_category_active/i18n/uom_category_active.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * uom_category_active +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: uom_category_active +#: model:ir.model.fields,field_description:uom_category_active.field_uom_category__active +msgid "Active" +msgstr "" + +#. module: uom_category_active +#: model:ir.model.fields,help:uom_category_active.field_uom_category__active +msgid "" +"If unchecked, it will allow you to hide the product category without " +"removing it." +msgstr "" + +#. module: uom_category_active +#: model:ir.model,name:uom_category_active.model_uom_category +msgid "Product UoM Categories" +msgstr "" diff --git a/uom_category_active/models/__init__.py b/uom_category_active/models/__init__.py new file mode 100644 index 00000000000..86f4ecdedf6 --- /dev/null +++ b/uom_category_active/models/__init__.py @@ -0,0 +1 @@ +from . import uom_category diff --git a/uom_category_active/models/uom_category.py b/uom_category_active/models/uom_category.py new file mode 100644 index 00000000000..9bdc0afc036 --- /dev/null +++ b/uom_category_active/models/uom_category.py @@ -0,0 +1,28 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# Copyright 2023 PESOL - Angel Moya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class UomCategory(models.Model): + _inherit = "uom.category" + + active = fields.Boolean( + default=True, + help="If unchecked, it will allow you to hide the " + "product category without removing it.", + ) + + @api.model_create_multi + def create(self, vals_list): + categs = super().create(vals_list) + categs.filtered(lambda x: not x.active).mapped("uom_ids").write( + {"active": False} + ) + return categs + + def write(self, vals): + if "active" in vals and not vals.get("active"): + self.mapped("uom_ids").write({"active": False}) + return super().write(vals) diff --git a/uom_category_active/pyproject.toml b/uom_category_active/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/uom_category_active/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/uom_category_active/readme/CONTRIBUTORS.md b/uom_category_active/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..048bcc69289 --- /dev/null +++ b/uom_category_active/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [PESOL](https://pesol.es): + - Angel Moya diff --git a/uom_category_active/readme/DESCRIPTION.md b/uom_category_active/readme/DESCRIPTION.md new file mode 100644 index 00000000000..23d051663ea --- /dev/null +++ b/uom_category_active/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows you to archive UoM categories. diff --git a/uom_category_active/readme/USAGE.md b/uom_category_active/readme/USAGE.md new file mode 100644 index 00000000000..90dae2d044b --- /dev/null +++ b/uom_category_active/readme/USAGE.md @@ -0,0 +1,12 @@ +To use this module, you need to: + +1. Active Unit of Measures on *Inventory \> Configuration \> Settings + \[Products/Units of Measures\]* . +2. Go to *Inventory \> Configuration \> Unit of Measures \> UoM + Categories*. +3. Select a UoM category or create a new one. +4. Click on the smart button Archive (this action will set active field + to False). + +Note: If there are UoM in the category to be archived, this UoM will be +archived to. diff --git a/uom_category_active/static/description/icon.png b/uom_category_active/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/uom_category_active/static/description/icon.png differ diff --git a/uom_category_active/static/description/index.html b/uom_category_active/static/description/index.html new file mode 100644 index 00000000000..c598641fa4f --- /dev/null +++ b/uom_category_active/static/description/index.html @@ -0,0 +1,442 @@ + + + + + +UoM Category Active + + + +
+

UoM Category Active

+ + +

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

+

This module allows you to archive UoM categories.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Active Unit of Measures on Inventory > Configuration > Settings +[Products/Units of Measures] .
  2. +
  3. Go to Inventory > Configuration > Unit of Measures > UoM +Categories.
  4. +
  5. Select a UoM category or create a new one.
  6. +
  7. Click on the smart button Archive (this action will set active field +to False).
  8. +
+

Note: If there are UoM in the category to be archived, this UoM will be +archived to.

+
+
+

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

+
    +
  • PESOL
  • +
+
+
+

Contributors

+
    +
  • PESOL:
      +
    • Angel Moya
    • +
    +
  • +
+
+
+

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/uom_category_active/tests/__init__.py b/uom_category_active/tests/__init__.py new file mode 100644 index 00000000000..d49945b0aa6 --- /dev/null +++ b/uom_category_active/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_uom_category_active diff --git a/uom_category_active/tests/test_uom_category_active.py b/uom_category_active/tests/test_uom_category_active.py new file mode 100644 index 00000000000..8bf92af5e7b --- /dev/null +++ b/uom_category_active/tests/test_uom_category_active.py @@ -0,0 +1,23 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# Copyright 2023 PESOL - Angel Moya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class TestUomCategoryActive(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + categ_obj = cls.env["uom.category"] + cls.uom_categ = categ_obj.create( + {"name": "Test UoM Category", "uom_ids": [(0, 0, {"name": "Test UoM"})]} + ) + cls.uom = cls.uom_categ.uom_ids[0] + + def test_archive_non_empty_categories(self): + self.assertTrue(self.uom_categ.active) + self.assertTrue(self.uom.active) + self.uom_categ.active = False + self.assertFalse(self.uom_categ.active) + self.assertFalse(self.uom.active) diff --git a/uom_category_active/views/uom_category_views.xml b/uom_category_active/views/uom_category_views.xml new file mode 100644 index 00000000000..14ac1b5e696 --- /dev/null +++ b/uom_category_active/views/uom_category_views.xml @@ -0,0 +1,21 @@ + + + + uom.category.form.inherit + uom.category + + + + + + + + + + +