Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions base_tier_validation_black_list/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
.. 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:de55c6a829c3a38b7d3f238aa2256fc7d62d88c4dc70a606e68371e4e3c5d06e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/2025-12-CL-Fields-Like-Blacklist-Tier-Validation/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-2025-12-CL-Fields-Like-Blacklist-Tier-Validation/server-ux-2025-12-CL-Fields-Like-Blacklist-Tier-Validation-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=2025-12-CL-Fields-Like-Blacklist-Tier-Validation
: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 <https://odoo-community.org/page/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 <https://github.com/OCA/server-ux/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 <https://github.com/OCA/server-ux/issues/new?body=module:%20base_tier_validation_black_list%0Aversion:%202025-12-CL-Fields-Like-Blacklist-Tier-Validation%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Trescloud

Contributors
------------

- `Trescloud <https://www.trescloud.com>`__

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

This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/2025-12-CL-Fields-Like-Blacklist-Tier-Validation/base_tier_validation_black_list>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions base_tier_validation_black_list/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions base_tier_validation_black_list/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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)",
"website": "https://github.com/OCA/server-ux",
"depends": ["base_tier_validation"],
"data": [
"views/tier_validation_exception_views.xml",
],
"demo": [],
}
2 changes: 2 additions & 0 deletions base_tier_validation_black_list/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import tier_validation
from . import tier_validation_exception
36 changes: 36 additions & 0 deletions base_tier_validation_black_list/models/tier_validation.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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,
)
3 changes: 3 additions & 0 deletions base_tier_validation_black_list/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions base_tier_validation_black_list/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Trescloud](https://www.trescloud.com)
- César León
1 change: 1 addition & 0 deletions base_tier_validation_black_list/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows you to define the fields that cannot be edited during a validation.
4 changes: 4 additions & 0 deletions base_tier_validation_black_list/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.
Loading