From d572d3dd0c2740a57fc88d8b00bf6afd0e665174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Le=C3=B3n?= Date: Fri, 7 Nov 2025 09:07:04 -0500 Subject: [PATCH 1/2] [IMP][CL] Blacklist in exceptions --- .../models/tier_validation.py | 24 +++++++++++++++---- .../models/tier_validation_exception.py | 7 ++++++ .../tests/test_tier_validation.py | 1 + .../views/tier_validation_exception_view.xml | 1 + 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/base_tier_validation/models/tier_validation.py b/base_tier_validation/models/tier_validation.py index 6479bb5bff..0f18257d0b 100644 --- a/base_tier_validation/models/tier_validation.py +++ b/base_tier_validation/models/tier_validation.py @@ -274,23 +274,37 @@ def evaluate_tier(self, tier): else: return self - @api.model - def _get_validation_exceptions(self, extra_domain=None, add_base_exceptions=True): - """Return Tier Validation Exception field names that matchs custom domain.""" + def _get_exception_fields(self, is_black_list=False, extra_domain=False): exception_fields = ( self.env["tier.validation.exception"] .sudo() .search( [ ("model_name", "=", self._name), - ("company_id", "in", [False] + self._get_company().ids), + ("company_id", "in", [False] + self.env.company.ids), + ("is_black_list", "=", is_black_list), "|", ("group_ids", "in", self.env.user.groups_id.ids), ("group_ids", "=", False), *(extra_domain or []), ] ) - .mapped("field_ids.name") + ) + if is_black_list: + return set( + ( + exception_fields.valid_model_field_ids + - exception_fields.mapped("field_ids") + ).mapped("name") + ) + return set(exception_fields.mapped("field_ids.name")) + + @api.model + def _get_validation_exceptions(self, extra_domain=None, add_base_exceptions=True): + """Return Tier Validation Exception field names that matchs custom domain.""" + exception_fields = list( + self._get_exception_fields(extra_domain=extra_domain) + or self._get_exception_fields(is_black_list=True, extra_domain=extra_domain) ) if add_base_exceptions: exception_fields += BASE_EXCEPTION_FIELDS diff --git a/base_tier_validation/models/tier_validation_exception.py b/base_tier_validation/models/tier_validation_exception.py index ad0f35dc4c..5c2d75d025 100644 --- a/base_tier_validation/models/tier_validation_exception.py +++ b/base_tier_validation/models/tier_validation_exception.py @@ -59,6 +59,13 @@ def _get_tier_validation_model_names(self): string="Groups", help="Allowed groups to use this Tier Validation Exception", ) + is_black_list = fields.Boolean( + string="Use like Black List", + help="If this option is selected, this exception will act " + "as a blacklist, meaning that the selected fields will NOT " + "be allowed for the specified model, but editing will be " + "enabled for all others.", + ) @api.depends("model_id") def _compute_valid_model_field_ids(self): diff --git a/base_tier_validation/tests/test_tier_validation.py b/base_tier_validation/tests/test_tier_validation.py index 4103d54853..01357bb55f 100644 --- a/base_tier_validation/tests/test_tier_validation.py +++ b/base_tier_validation/tests/test_tier_validation.py @@ -947,6 +947,7 @@ def test_27_change_field_exception_validation(self): # Able to write test_validation_field after validation with mock.patch.multiple( TV, + _get_exception_fields=mock.MagicMock(return_value=_tvf), _get_validation_exceptions=mock.MagicMock(return_value=_tvf), _get_after_validation_exceptions=mock.MagicMock(return_value=_rv), ): diff --git a/base_tier_validation/views/tier_validation_exception_view.xml b/base_tier_validation/views/tier_validation_exception_view.xml index 506e312d1a..1f718d19b2 100644 --- a/base_tier_validation/views/tier_validation_exception_view.xml +++ b/base_tier_validation/views/tier_validation_exception_view.xml @@ -36,6 +36,7 @@ name="model_id" options="{'no_create': True, 'no_open': True}" /> + Date: Wed, 12 Nov 2025 12:12:54 -0500 Subject: [PATCH 2/2] =?UTF-8?q?[UPD][CL]=20Actualizaci=C3=B3n=20de=20manif?= =?UTF-8?q?est?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base_tier_validation/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_tier_validation/__manifest__.py b/base_tier_validation/__manifest__.py index 005c6ca483..50ebd4cdc3 100644 --- a/base_tier_validation/__manifest__.py +++ b/base_tier_validation/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Base Tier Validation", "summary": "Implement a validation process based on tiers.", - "version": "18.0.3.1.0", + "version": "18.0.3.1.1", "development_status": "Mature", "maintainers": ["LoisRForgeFlow"], "category": "Tools",