diff --git a/README.md b/README.md
index 69c5528..a0f8ddc 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ addon | version | summary
[multi_step_wizard](multi_step_wizard/) | 2.0.1.0.0| Multi-Steps Wizards
[base_technical_features](base_technical_features/) | 2.0.1.1.0| Access to technical features without activating debug mode
[base_tier_validation_formula](base_tier_validation_formula/) | 2.0.2.0.0| Formulas for Base tier validation
-[base_tier_validation](base_tier_validation/) | 2.0.2.4.0| Implement a validation process based on tiers.
+[base_tier_validation](base_tier_validation/) | 2.0.2.5.0| Implement a validation process based on tiers.
[base_search_custom_field_filter](base_search_custom_field_filter/) | 2.0.1.0.0| Add custom filters for fields via UI
[base_revision](base_revision/) | 2.0.1.0.1| Keep track of revised document
[base_export_manager](base_export_manager/) | 2.0.1.0.1| Manage model export profiles
diff --git a/base_tier_validation/__manifest__.py b/base_tier_validation/__manifest__.py
index a0476c3..b54ce41 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": "2.0.2.4.0",
+ "version": "2.0.2.5.0",
"development_status": "Mature",
"maintainers": ["LoisRForgeFlow"],
"category": "Tools",
diff --git a/base_tier_validation/i18n/base_tier_validation.pot b/base_tier_validation/i18n/base_tier_validation.pot
index 7fea642..8cf7107 100644
--- a/base_tier_validation/i18n/base_tier_validation.pot
+++ b/base_tier_validation/i18n/base_tier_validation.pot
@@ -106,7 +106,7 @@ msgstr ""
#. module: base_tier_validation
#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__group
-msgid "Any user in a specific group."
+msgid "Any user in a specific group"
msgstr ""
#. module: base_tier_validation
@@ -237,6 +237,11 @@ msgstr ""
msgid "Done by"
msgstr ""
+#. module: base_tier_validation
+#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__field
+msgid "Field in related record"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_review.py:0
#, python-format
@@ -406,6 +411,12 @@ msgstr ""
msgid "Reviewer"
msgstr ""
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_field_id
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_field_id
+msgid "Reviewer field"
+msgstr ""
+
#. module: base_tier_validation
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_group_id
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_group_id
@@ -461,6 +472,12 @@ msgstr ""
msgid "The review has been reset by %s."
msgstr ""
+#. module: base_tier_validation
+#: code:addons/base_tier_validation/models/tier_review.py:0
+#, python-format
+msgid "There are no res.users in the selected field"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_validation.py:0
#, python-format
@@ -531,6 +548,11 @@ msgstr ""
msgid "Users"
msgstr ""
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__valid_reviewer_field_ids
+msgid "Valid Reviewer Field"
+msgstr ""
+
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_validation_label
msgid "Validate"
diff --git a/base_tier_validation/i18n/es.po b/base_tier_validation/i18n/es.po
index 0e09019..964f694 100644
--- a/base_tier_validation/i18n/es.po
+++ b/base_tier_validation/i18n/es.po
@@ -120,8 +120,8 @@ msgstr "Todos"
#. module: base_tier_validation
#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__group
-msgid "Any user in a specific group."
-msgstr "Cualquier usuario en el grupo especificado."
+msgid "Any user in a specific group"
+msgstr ""
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_definition_view_form
@@ -253,6 +253,11 @@ msgstr "Hecho Por"
msgid "Done by"
msgstr "Hecho Por"
+#. module: base_tier_validation
+#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__field
+msgid "Field in related record"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_review.py:0
#, python-format
@@ -429,6 +434,12 @@ msgstr "Revisor"
msgid "Reviewer"
msgstr "Revisor"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_field_id
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_field_id
+msgid "Reviewer field"
+msgstr ""
+
#. module: base_tier_validation
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_group_id
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_group_id
@@ -484,6 +495,12 @@ msgstr "Esta operación está en proceso de validación."
msgid "The review has been reset by %s."
msgstr ""
+#. module: base_tier_validation
+#: code:addons/base_tier_validation/models/tier_review.py:0
+#, python-format
+msgid "There are no res.users in the selected field"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_validation.py:0
#, python-format
@@ -558,6 +575,11 @@ msgstr ""
msgid "Users"
msgstr "Usuarios"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__valid_reviewer_field_ids
+msgid "Valid Reviewer Field"
+msgstr ""
+
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_validation_label
msgid "Validate"
@@ -598,6 +620,9 @@ msgstr "Validaciones"
msgid "e.g. Tier Validation for..."
msgstr "ej. Validación de Nivel por..."
+#~ msgid "Any user in a specific group."
+#~ msgstr "Cualquier usuario en el grupo especificado."
+
#~ msgid "Tier"
#~ msgstr "Nivel"
diff --git a/base_tier_validation/i18n/fr.po b/base_tier_validation/i18n/fr.po
index b9f7010..27311fd 100644
--- a/base_tier_validation/i18n/fr.po
+++ b/base_tier_validation/i18n/fr.po
@@ -122,8 +122,8 @@ msgstr "Tout"
#. module: base_tier_validation
#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__group
-msgid "Any user in a specific group."
-msgstr "Tout utilisateur d'un groupe spécifique."
+msgid "Any user in a specific group"
+msgstr ""
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_definition_view_form
@@ -253,6 +253,11 @@ msgstr "Fait par"
msgid "Done by"
msgstr "Fait par"
+#. module: base_tier_validation
+#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__field
+msgid "Field in related record"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_review.py:0
#, python-format
@@ -422,6 +427,12 @@ msgstr "Vérification"
msgid "Reviewer"
msgstr "Vérificateur"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_field_id
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_field_id
+msgid "Reviewer field"
+msgstr ""
+
#. module: base_tier_validation
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_group_id
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_group_id
@@ -477,6 +488,12 @@ msgstr ""
msgid "The review has been reset by %s."
msgstr ""
+#. module: base_tier_validation
+#: code:addons/base_tier_validation/models/tier_review.py:0
+#, python-format
+msgid "There are no res.users in the selected field"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_validation.py:0
#, python-format
@@ -547,6 +564,11 @@ msgstr "A faire par"
msgid "Users"
msgstr "Utilisateurs"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__valid_reviewer_field_ids
+msgid "Valid Reviewer Field"
+msgstr ""
+
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_validation_label
msgid "Validate"
@@ -585,3 +607,6 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_definition_view_form
msgid "e.g. Tier Validation for..."
msgstr "ie Validation par un tiers pour..."
+
+#~ msgid "Any user in a specific group."
+#~ msgstr "Tout utilisateur d'un groupe spécifique."
diff --git a/base_tier_validation/i18n/nl_NL.po b/base_tier_validation/i18n/nl_NL.po
index 7f5c480..b9c0784 100644
--- a/base_tier_validation/i18n/nl_NL.po
+++ b/base_tier_validation/i18n/nl_NL.po
@@ -109,8 +109,8 @@ msgstr "Alle"
#. module: base_tier_validation
#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__group
-msgid "Any user in a specific group."
-msgstr "Elke gebruiker in een specifieke groep."
+msgid "Any user in a specific group"
+msgstr ""
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_definition_view_form
@@ -240,6 +240,11 @@ msgstr "Gedaan door"
msgid "Done by"
msgstr "Gedaan door"
+#. module: base_tier_validation
+#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__field
+msgid "Field in related record"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_review.py:0
#, python-format
@@ -411,6 +416,12 @@ msgstr "Beoordeling"
msgid "Reviewer"
msgstr "Beoordelaar"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_field_id
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_field_id
+msgid "Reviewer field"
+msgstr ""
+
#. module: base_tier_validation
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_group_id
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_group_id
@@ -466,6 +477,12 @@ msgstr "De bewerking is onder validatie."
msgid "The review has been reset by %s."
msgstr ""
+#. module: base_tier_validation
+#: code:addons/base_tier_validation/models/tier_review.py:0
+#, python-format
+msgid "There are no res.users in the selected field"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_validation.py:0
#, python-format
@@ -540,6 +557,11 @@ msgstr ""
msgid "Users"
msgstr "Gebruikers"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__valid_reviewer_field_ids
+msgid "Valid Reviewer Field"
+msgstr ""
+
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_validation_label
msgid "Validate"
@@ -579,6 +601,9 @@ msgstr "Validaties"
msgid "e.g. Tier Validation for..."
msgstr "bijv. Tier validatie voor..."
+#~ msgid "Any user in a specific group."
+#~ msgstr "Elke gebruiker in een specifieke groep."
+
#~ msgid "Tier"
#~ msgstr "Tier"
diff --git a/base_tier_validation/i18n/zh_CN.po b/base_tier_validation/i18n/zh_CN.po
index 0fb81e1..3375986 100644
--- a/base_tier_validation/i18n/zh_CN.po
+++ b/base_tier_validation/i18n/zh_CN.po
@@ -109,8 +109,8 @@ msgstr "所有"
#. module: base_tier_validation
#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__group
-msgid "Any user in a specific group."
-msgstr "指定权限组"
+msgid "Any user in a specific group"
+msgstr ""
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_definition_view_form
@@ -240,6 +240,11 @@ msgstr "审批人"
msgid "Done by"
msgstr "审批人"
+#. module: base_tier_validation
+#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_definition__review_type__field
+msgid "Field in related record"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_review.py:0
#, python-format
@@ -409,6 +414,12 @@ msgstr "审批"
msgid "Reviewer"
msgstr "审批人"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_field_id
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_field_id
+msgid "Reviewer field"
+msgstr ""
+
#. module: base_tier_validation
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__reviewer_group_id
#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__reviewer_group_id
@@ -464,6 +475,12 @@ msgstr "该操作正在审批中。"
msgid "The review has been reset by %s."
msgstr ""
+#. module: base_tier_validation
+#: code:addons/base_tier_validation/models/tier_review.py:0
+#, python-format
+msgid "There are no res.users in the selected field"
+msgstr ""
+
#. module: base_tier_validation
#: code:addons/base_tier_validation/models/tier_validation.py:0
#, python-format
@@ -538,6 +555,11 @@ msgstr ""
msgid "Users"
msgstr "用户"
+#. module: base_tier_validation
+#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__valid_reviewer_field_ids
+msgid "Valid Reviewer Field"
+msgstr ""
+
#. module: base_tier_validation
#: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_validation_label
msgid "Validate"
@@ -577,6 +599,9 @@ msgstr "审批"
msgid "e.g. Tier Validation for..."
msgstr "例如:审批层级用于..."
+#~ msgid "Any user in a specific group."
+#~ msgstr "指定权限组"
+
#~ msgid "Tier"
#~ msgstr "层级"
diff --git a/base_tier_validation/models/tier_definition.py b/base_tier_validation/models/tier_definition.py
index 4091a5a..4d22170 100644
--- a/base_tier_validation/models/tier_definition.py
+++ b/base_tier_validation/models/tier_definition.py
@@ -34,13 +34,23 @@ class TierDefinition(models.Model):
default="individual",
selection=[
("individual", "Specific user"),
- ("group", "Any user in a specific group."),
+ ("group", "Any user in a specific group"),
+ ("field", "Field in related record"),
],
)
reviewer_id = fields.Many2one(comodel_name="res.users", string="Reviewer")
reviewer_group_id = fields.Many2one(
comodel_name="res.groups", string="Reviewer group"
)
+ reviewer_field_id = fields.Many2one(
+ comodel_name="ir.model.fields",
+ string="Reviewer field",
+ domain="[('id', 'in', valid_reviewer_field_ids)]",
+ )
+ valid_reviewer_field_ids = fields.One2many(
+ comodel_name="ir.model.fields",
+ compute="_compute_domain_reviewer_field",
+ )
definition_type = fields.Selection(
string="Definition", selection=[("domain", "Domain")], default="domain"
)
@@ -68,3 +78,10 @@ class TierDefinition(models.Model):
def onchange_review_type(self):
self.reviewer_id = None
self.reviewer_group_id = None
+
+ @api.depends("review_type", "model_id")
+ def _compute_domain_reviewer_field(self):
+ for rec in self:
+ rec.valid_reviewer_field_ids = self.env["ir.model.fields"].search(
+ [("model", "=", rec.model), ("relation", "=", "res.users")]
+ )
diff --git a/base_tier_validation/models/tier_review.py b/base_tier_validation/models/tier_review.py
index 091c565..42f7f5f 100644
--- a/base_tier_validation/models/tier_review.py
+++ b/base_tier_validation/models/tier_review.py
@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from flectra import _, api, fields, models
+from flectra.exceptions import ValidationError
class TierReview(models.Model):
@@ -29,6 +30,9 @@ class TierReview(models.Model):
reviewer_group_id = fields.Many2one(
related="definition_id.reviewer_group_id", readonly=True
)
+ reviewer_field_id = fields.Many2one(
+ related="definition_id.reviewer_field_id", readonly=True
+ )
reviewer_ids = fields.Many2many(
string="Reviewers",
comodel_name="res.users",
@@ -94,4 +98,12 @@ class TierReview(models.Model):
rec.todo_by = todo_by
def _get_reviewers(self):
- return self.reviewer_id + self.reviewer_group_id.users
+ if self.reviewer_id or self.reviewer_group_id.users:
+ return self.reviewer_id + self.reviewer_group_id.users
+ reviewer_field = self.env["res.users"]
+ if self.reviewer_field_id:
+ resource = self.env[self.model].browse(self.res_id)
+ reviewer_field = getattr(resource, self.reviewer_field_id.name, False)
+ if not reviewer_field or not reviewer_field._name == "res.users":
+ raise ValidationError(_("There are no res.users in the selected field"))
+ return reviewer_field
diff --git a/base_tier_validation/tests/test_tier_validation.py b/base_tier_validation/tests/test_tier_validation.py
index b4aa5f0..8dbe60a 100644
--- a/base_tier_validation/tests/test_tier_validation.py
+++ b/base_tier_validation/tests/test_tier_validation.py
@@ -413,6 +413,29 @@ class TierTierValidation(CommonTierValidation):
)
self.assertEquals(len(records), 0)
+ def test_18_test_review_by_res_users_field(self):
+ selected_field = self.env["ir.model.fields"].search(
+ [("model", "=", self.test_model._name), ("name", "=", "user_id")]
+ )
+ test_record = self.test_model.create(
+ {"test_field": 2.5, "user_id": self.test_user_2.id}
+ )
+
+ definition = self.env["tier.definition"].create(
+ {
+ "model_id": self.tester_model.id,
+ "review_type": "field",
+ "reviewer_field_id": selected_field.id,
+ "definition_domain": "[('test_field', '>', 1.0)]",
+ "approve_sequence": True,
+ }
+ )
+
+ reviews = test_record.request_validation()
+ review = reviews.filtered(lambda r: r.definition_id == definition)
+ self.assertTrue(review)
+ self.assertEqual(review.reviewer_ids, self.test_user_2)
+
@tagged("at_install")
class TierTierValidationView(CommonTierValidation):
diff --git a/base_tier_validation/views/tier_definition_view.xml b/base_tier_validation/views/tier_definition_view.xml
index 81b5a17..94a06d7 100644
--- a/base_tier_validation/views/tier_definition_view.xml
+++ b/base_tier_validation/views/tier_definition_view.xml
@@ -12,6 +12,7 @@
+
@@ -55,6 +56,12 @@
name="reviewer_group_id"
attrs="{'invisible': [('review_type', '!=', 'group')]}"
/>
+
+