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
29 changes: 24 additions & 5 deletions base_tier_validation/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. 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
====================
Expand All @@ -17,7 +13,7 @@ Base Tier Validation
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
:target: https://odoo-community.org/page/development-status
:alt: Mature
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |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%2Fserver--ux-lightgray.png?logo=github
Expand Down Expand Up @@ -103,6 +99,29 @@ To configure Tier Validation Exceptions, you need to:
- If check *Write after Validation* and *Write under Validation*,
records will be able to be modified defined fields always.

Usage
=====

**Bypass tier validation context key**

``skip_validation_check``: This flag will bypass the tier validation
workflow. When this context key is set to True, aall tier validations
within the write and \_write methods are bypassed.

This is the ideal flag to use in your unit tests.

.. code:: python

# Example: Confirming a sale order in a unit test
# without triggering the tier validation workflow.
sale_order.with_context(skip_validation_check=True).action_confirm()

**Skip initial state check**

``skip_check_state_condition``: This forces the initial state check to
pass. This makes the system believe the record is in a valid state to
behin the validation process, even if it isn't.

Known issues / Roadmap
======================

Expand Down
2 changes: 1 addition & 1 deletion base_tier_validation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Base Tier Validation",
"summary": "Implement a validation process based on tiers.",
"version": "17.0.4.0.0",
"version": "17.0.4.0.1",
"development_status": "Mature",
"maintainers": ["LoisRForgeFlow"],
"category": "Tools",
Expand Down
13 changes: 7 additions & 6 deletions base_tier_validation/models/tier_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,16 @@ def _check_tier_state_transition(self, vals):
) not in (self._state_to + [self._cancel_state])

def write(self, vals):
self._tier_validation_check_state_on_write(vals)
self._tier_validation_check_write_allowed(vals)
self._tier_validation_check_write_remove_reviews(vals)
if not self._context.get("skip_validation_check"):
self._tier_validation_check_state_on_write(vals)
self._tier_validation_check_write_allowed(vals)
self._tier_validation_check_write_remove_reviews(vals)
return super().write(vals)

def _write(self, vals):
if self._tier_validation_state_field_is_computed:
if self._tier_validation_state_field_is_computed and not self._context.get(
"skip_validation_check"
):
self._tier_validation_check_state_on_write(vals)
self._tier_validation_check_write_remove_reviews(vals)
return super()._write(vals)
Expand Down Expand Up @@ -437,7 +440,6 @@ def _tier_validation_check_write_allowed(self, vals):
rec.review_ids
and rec._check_tier_state_transition(vals)
and not rec._check_allow_write_under_validation(vals)
and not rec._context.get("skip_validation_check")
):
(
allowed_fields,
Expand All @@ -464,7 +466,6 @@ def _tier_validation_check_write_allowed(self, vals):
and rec._tier_validation_get_current_state_value()
in (self._state_to + [self._cancel_state])
and not rec._check_allow_write_after_validation(vals)
and not rec._context.get("skip_validation_check")
):
(
allowed_fields,
Expand Down
16 changes: 16 additions & 0 deletions base_tier_validation/readme/USAGE.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**Bypass tier validation context key**

```skip_validation_check```: This flag will bypass the tier validation
workflow. When this context key is set to True, aall tier validations within the write and _write methods are bypassed.

This is the ideal flag to use in your unit tests.

``` python
# Example: Confirming a sale order in a unit test
# without triggering the tier validation workflow.
sale_order.with_context(skip_validation_check=True).action_confirm()
```

**Skip initial state check**

```skip_check_state_condition```: This forces the initial state check to pass. This makes the system believe the record is in a valid state to begin the validation process, even if it isn't.
Loading