diff --git a/base_tier_validation_black_list/README.rst b/base_tier_validation_black_list/README.rst new file mode 100644 index 0000000000..e8a01e17a9 --- /dev/null +++ b/base_tier_validation_black_list/README.rst @@ -0,0 +1,104 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=============================== +Base Tier Validation Black List +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d3106489332a72307c9a04fe24500526ba7fa6726d435165ac4c6d0369587fa3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fserver--ux-lightgray.png?logo=github + :target: https://github.com/OCA/server-ux/tree/18.0/base_tier_validation_black_list + :alt: OCA/server-ux +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-ux-18-0/server-ux-18-0-base_tier_validation_black_list + :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/server-ux&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to define the fields that cannot be edited during +a validation. + +.. 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: + +Usage +===== + +A clear use case is when multiple modules are expected to be installed. +This will create fields in various models, such as sales or purchase +orders. To avoid exhaustive maintenance, instead of adding exceptions to +allow editing, we add exceptions for the fields that will not be edited. + +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 +------- + +* Trescloud + +Contributors +------------ + +- `Trescloud `__ + + - César León + +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-CILC98| image:: https://github.com/CILC98.png?size=40px + :target: https://github.com/CILC98 + :alt: CILC98 + +Current `maintainer `__: + +|maintainer-CILC98| + +This module is part of the `OCA/server-ux `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_tier_validation_black_list/__init__.py b/base_tier_validation_black_list/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/base_tier_validation_black_list/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_tier_validation_black_list/__manifest__.py b/base_tier_validation_black_list/__manifest__.py new file mode 100644 index 0000000000..3cf5199963 --- /dev/null +++ b/base_tier_validation_black_list/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2025 Trescloud and Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Base Tier Validation Black List", + "summary": """ + Exception rules for tier validation used like a black list. + The fields in the exception rules will be restricted + """, + "version": "18.0.1.0.1", + "category": "Tools", + "license": "AGPL-3", + "development_status": "Alpha", + "author": "Trescloud,Odoo Community Association (OCA)", + "maintainers": ["CILC98"], + "website": "https://github.com/OCA/server-ux", + "depends": ["base_tier_validation"], + "data": [ + "views/tier_validation_exception_views.xml", + ], + "demo": [], +} diff --git a/base_tier_validation_black_list/models/__init__.py b/base_tier_validation_black_list/models/__init__.py new file mode 100644 index 0000000000..07c4e99a66 --- /dev/null +++ b/base_tier_validation_black_list/models/__init__.py @@ -0,0 +1,2 @@ +from . import tier_validation +from . import tier_validation_exception diff --git a/base_tier_validation_black_list/models/tier_validation.py b/base_tier_validation_black_list/models/tier_validation.py new file mode 100644 index 0000000000..686a0f2132 --- /dev/null +++ b/base_tier_validation_black_list/models/tier_validation.py @@ -0,0 +1,36 @@ +from odoo import api, models + + +class TierValidation(models.AbstractModel): + _inherit = "tier.validation" + + @api.model + def _get_exception_fields(self, extra_domain=None): + """ + Return Tier Validation Exception field names that matchs custom domain + taken account blacklist exceptions. + """ + extra_domain = extra_domain or [] + extra_domain.append(("is_blacklist", "=", False)) + res = super()._get_exception_fields(extra_domain=extra_domain) + extra_domain.remove(("is_blacklist", "=", False)) + domain = [ + ("model_name", "=", self._name), + ("company_id", "in", [False] + self._get_company().ids), + ("is_blacklist", "=", True), + "|", + ("group_ids", "in", self.env.user.groups_id.ids), + ("group_ids", "=", False), + *(extra_domain or []), + ] + exception_ids = self.env["tier.validation.exception"].sudo().search(domain) + if exception_ids: + all_fields_allowed = exception_ids[0].valid_model_field_ids.mapped("name") + fields_to_add = set(all_fields_allowed) - set( + exception_ids.mapped("field_ids.name") + ) + fields_allowed = ( + set(res) - set(exception_ids.mapped("field_ids.name")) + ) | fields_to_add + res = list(fields_allowed) + return res diff --git a/base_tier_validation_black_list/models/tier_validation_exception.py b/base_tier_validation_black_list/models/tier_validation_exception.py new file mode 100644 index 0000000000..33ef471a76 --- /dev/null +++ b/base_tier_validation_black_list/models/tier_validation_exception.py @@ -0,0 +1,14 @@ +from odoo import fields, models + + +class TierValidationException(models.Model): + _inherit = "tier.validation.exception" + + is_blacklist = fields.Boolean( + string="Is Blacklist Exception", + help="If checked, the selected fields will be skiped " + "in allowed fields for tier validation.", + ) + field_ids = fields.Many2many( + required=False, + ) diff --git a/base_tier_validation_black_list/pyproject.toml b/base_tier_validation_black_list/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/base_tier_validation_black_list/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_tier_validation_black_list/readme/CONTRIBUTORS.md b/base_tier_validation_black_list/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..00c179be6c --- /dev/null +++ b/base_tier_validation_black_list/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Trescloud](https://www.trescloud.com) + - César León \ No newline at end of file diff --git a/base_tier_validation_black_list/readme/DESCRIPTION.md b/base_tier_validation_black_list/readme/DESCRIPTION.md new file mode 100644 index 0000000000..e28793ebe6 --- /dev/null +++ b/base_tier_validation_black_list/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows you to define the fields that cannot be edited during a validation. \ No newline at end of file diff --git a/base_tier_validation_black_list/readme/USAGE.md b/base_tier_validation_black_list/readme/USAGE.md new file mode 100644 index 0000000000..abbb2d98cc --- /dev/null +++ b/base_tier_validation_black_list/readme/USAGE.md @@ -0,0 +1,4 @@ +A clear use case is when multiple modules are expected to be installed. +This will create fields in various models, such as sales or purchase orders. +To avoid exhaustive maintenance, instead of adding exceptions to allow editing, +we add exceptions for the fields that will not be edited. diff --git a/base_tier_validation_black_list/static/description/index.html b/base_tier_validation_black_list/static/description/index.html new file mode 100644 index 0000000000..c33fdc5f32 --- /dev/null +++ b/base_tier_validation_black_list/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Base Tier Validation Black List

+ +

Alpha License: AGPL-3 OCA/server-ux Translate me on Weblate Try me on Runboat

+

This module allows you to define the fields that cannot be edited during +a validation.

+
+

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

+ +
+

Usage

+

A clear use case is when multiple modules are expected to be installed. +This will create fields in various models, such as sales or purchase +orders. To avoid exhaustive maintenance, instead of adding exceptions to +allow editing, we add exceptions for the fields that will not be edited.

+
+
+

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

+
    +
  • Trescloud
  • +
+
+
+

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:

+

CILC98

+

This module is part of the OCA/server-ux project on GitHub.

+

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

+
+
+
+
+ + diff --git a/base_tier_validation_black_list/views/tier_validation_exception_views.xml b/base_tier_validation_black_list/views/tier_validation_exception_views.xml new file mode 100644 index 0000000000..208f8eb03f --- /dev/null +++ b/base_tier_validation_black_list/views/tier_validation_exception_views.xml @@ -0,0 +1,19 @@ + + + + tier.validation.exception.form + tier.validation.exception + + + + + + + not is_blacklist + + + +