From 87c6d50bf2e6d101ed9a376b8cedfc21a6db9944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Tue, 17 Oct 2023 17:03:22 +0200 Subject: [PATCH 1/3] [IMP] base_tier_validation: Add validation_status field to tier.validation TT33369 --- .../i18n/base_tier_validation.pot | 31 ++++++---- base_tier_validation/i18n/es.po | 61 +++++++------------ .../models/tier_validation.py | 28 +++++++++ 3 files changed, 71 insertions(+), 49 deletions(-) diff --git a/base_tier_validation/i18n/base_tier_validation.pot b/base_tier_validation/i18n/base_tier_validation.pot index 8393589331..777538eb80 100644 --- a/base_tier_validation/i18n/base_tier_validation.pot +++ b/base_tier_validation/i18n/base_tier_validation.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-24 06:38+0000\n" +"PO-Revision-Date: 2023-10-24 06:38+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -293,16 +295,6 @@ msgid "" "definition is triggered." msgstr "" -#. module: base_tier_validation -#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__archive_uid -msgid "Last Archived by" -msgstr "" - -#. module: base_tier_validation -#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__archive_date -msgid "Last Archived on" -msgstr "" - #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_comment_wizard____last_update #: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition____last_update @@ -405,6 +397,7 @@ msgstr "" #. openerp-web #: code:addons/base_tier_validation/static/src/xml/systray.xml:0 #: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_review__status__pending +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__pending #, python-format msgid "Pending" msgstr "" @@ -422,6 +415,7 @@ msgstr "" #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__rejected #: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_review__status__rejected +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__rejected msgid "Rejected" msgstr "" @@ -517,7 +511,6 @@ msgstr "" #. openerp-web #: code:addons/base_tier_validation/static/src/xml/tier_review_template.xml:0 #: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__sequence -#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__sequence #, python-format msgid "Sequence" msgstr "" @@ -567,6 +560,11 @@ msgid "" "Please request a validation." msgstr "" +#. module: base_tier_validation +#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__sequence +msgid "Tier" +msgstr "" + #. module: base_tier_validation #: model:ir.actions.act_window,name:base_tier_validation.tier_definition_action #: model:ir.model,name:base_tier_validation.model_tier_definition @@ -674,6 +672,7 @@ msgstr "" #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__validated +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__validated msgid "Validated" msgstr "" @@ -696,11 +695,21 @@ msgstr "" msgid "Validation Date" msgstr "" +#. module: base_tier_validation +#: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__validation_status +msgid "Validation Status" +msgstr "" + #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__review_ids msgid "Validations" msgstr "" +#. module: base_tier_validation +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__no +msgid "Without validation" +msgstr "" + #. module: base_tier_validation #: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_definition_view_form msgid "e.g. Tier Validation for..." diff --git a/base_tier_validation/i18n/es.po b/base_tier_validation/i18n/es.po index b463949725..f59c88f0b8 100644 --- a/base_tier_validation/i18n/es.po +++ b/base_tier_validation/i18n/es.po @@ -6,15 +6,16 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-03-16 11:46+0000\n" +"POT-Creation-Date: 2023-10-24 06:38+0000\n" +"PO-Revision-Date: 2023-10-24 08:41+0200\n" "Last-Translator: Ana Suárez \n" "Language-Team: none\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" +"X-Generator: Poedit 3.0.1\n" #. module: base_tier_validation #. openerp-web @@ -312,16 +313,6 @@ msgstr "" "Si está establecido, todos los posibles validadores serán notificados por " "email cuando esta definición se ejecute." -#. module: base_tier_validation -#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__archive_uid -msgid "Last Archived by" -msgstr "" - -#. module: base_tier_validation -#: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__archive_date -msgid "Last Archived on" -msgstr "" - #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_comment_wizard____last_update #: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition____last_update @@ -425,6 +416,7 @@ msgstr "" #. openerp-web #: code:addons/base_tier_validation/static/src/xml/systray.xml:0 #: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_review__status__pending +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__pending #, python-format msgid "Pending" msgstr "Pendiente" @@ -442,6 +434,7 @@ msgstr "Rechazar" #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__rejected #: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_review__status__rejected +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__rejected msgid "Rejected" msgstr "Rechazado" @@ -479,19 +472,16 @@ msgstr "Solicitado Por" #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_comment_wizard__res_id -#, fuzzy msgid "Res" msgstr "Revisiones" #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_comment_wizard__res_model -#, fuzzy msgid "Res Model" msgstr "Modelo" #. module: base_tier_validation #: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_validation_buttons -#, fuzzy msgid "Restart Validation" msgstr "Volver a empezar validación" @@ -540,7 +530,6 @@ msgstr "Revisiones" #. openerp-web #: code:addons/base_tier_validation/static/src/xml/tier_review_template.xml:0 #: model:ir.model.fields,field_description:base_tier_validation.field_tier_definition__sequence -#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__sequence #, python-format msgid "Sequence" msgstr "Secuencia" @@ -592,6 +581,11 @@ msgstr "" "Esta acción necesita ser validada para algún registro.\n" "Por favor, solicita una validación." +#. module: base_tier_validation +#: model:ir.model.fields,field_description:base_tier_validation.field_tier_review__sequence +msgid "Tier" +msgstr "Nivel" + #. module: base_tier_validation #: model:ir.actions.act_window,name:base_tier_validation.tier_definition_action #: model:ir.model,name:base_tier_validation.model_tier_definition @@ -692,7 +686,7 @@ msgstr "" #. module: base_tier_validation #: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_validation_label msgid "Validate" -msgstr "" +msgstr "Validado" #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_comment_wizard__validate_reject @@ -702,6 +696,7 @@ msgstr "Validado" #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__validated +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__validated msgid "Validated" msgstr "Validado" @@ -724,32 +719,22 @@ msgstr "Validado por" msgid "Validation Date" msgstr "Fecha de Validación" +#. module: base_tier_validation +#: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__validation_status +msgid "Validation Status" +msgstr "Estado de validación" + #. module: base_tier_validation #: model:ir.model.fields,field_description:base_tier_validation.field_tier_validation__review_ids msgid "Validations" msgstr "Validaciones" +#. module: base_tier_validation +#: model:ir.model.fields.selection,name:base_tier_validation.selection__tier_validation__validation_status__no +msgid "Without validation" +msgstr "Sin validación" + #. module: base_tier_validation #: model_terms:ir.ui.view,arch_db:base_tier_validation.tier_definition_view_form msgid "e.g. Tier Validation for..." msgstr "ej. Validación de Nivel por..." - -#~ msgid "Tier" -#~ msgstr "Nivel" - -#~ msgid "A review was rejected by {}. ({})" -#~ msgstr "Una revisión fue rechaza por {}. ({})" - -#~ msgid "Any user in a specific group." -#~ msgstr "Cualquier usuario en el grupo especificado." - -#, fuzzy -#~| msgid "Sequence" -#~ msgid "Approve Sequence" -#~ msgstr "Secuencia" - -#~ msgid "Formula" -#~ msgstr "Fórmula" - -#~ msgid "Python Expression" -#~ msgstr "Expresión Python" diff --git a/base_tier_validation/models/tier_validation.py b/base_tier_validation/models/tier_validation.py index 68e8d49d2f..ea41baf508 100644 --- a/base_tier_validation/models/tier_validation.py +++ b/base_tier_validation/models/tier_validation.py @@ -31,15 +31,28 @@ class TierValidation(models.AbstractModel): auto_join=True, ) to_validate_message = fields.Html(compute="_compute_validated_rejected") + # TODO: Delete in v17 in favor of validation_status field validated = fields.Boolean( compute="_compute_validated_rejected", search="_search_validated" ) validated_message = fields.Html(compute="_compute_validated_rejected") need_validation = fields.Boolean(compute="_compute_need_validation") + # TODO: Delete in v17 in favor of validation_status field rejected = fields.Boolean( compute="_compute_validated_rejected", search="_search_rejected" ) rejected_message = fields.Html(compute="_compute_validated_rejected") + # Informative field (used in purchase_tier_validation), will be reliable as of v17 + validation_status = fields.Selection( + selection=[ + ("no", "Without validation"), + ("pending", "Pending"), + ("rejected", "Rejected"), + ("validated", "Validated"), + ], + default="no", + compute="_compute_validation_status", + ) reviewer_ids = fields.Many2many( string="Reviewers", comodel_name="res.users", @@ -165,6 +178,21 @@ def _compute_validated_rejected(self): rec.rejected_message = rec._get_rejected_message() rec.to_validate_message = rec._get_to_validate_message() + def _compute_validation_status(self): + for item in self: + if item.validated and not item.rejected: + item.validation_status = "validated" + elif not item.validated and item.rejected: + item.validation_status = "rejected" + elif ( + not item.validated + and not item.rejected + and any(item.review_ids.filtered(lambda x: x.status == "pending")) + ): + item.validation_status = "pending" + else: + item.validation_status = "no" + def _compute_next_review(self): for rec in self: review = rec.review_ids.sorted("sequence").filtered( From 3de4824019a54d688b39430b5bb26c70692f38f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Tue, 24 Oct 2023 08:59:10 +0200 Subject: [PATCH 2/3] [IMP] base_tier_validation: Add tier.validation.tester models to _get_tier_validation_model_names() Even if they are models that are only used in tests, it is necessary to add the tier.validation.tester and tier.validation.tester2 to the tier.definition's _get_tier_validation_model_names() method. TT33369 --- base_tier_validation/tests/common.py | 10 ++++++++-- .../tests/tier_validation_tester.py | 13 ++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/base_tier_validation/tests/common.py b/base_tier_validation/tests/common.py index 9ff9e0521f..98ded85241 100644 --- a/base_tier_validation/tests/common.py +++ b/base_tier_validation/tests/common.py @@ -13,9 +13,15 @@ def setUpClass(cls): cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() - from .tier_validation_tester import TierValidationTester, TierValidationTester2 + from .tier_validation_tester import ( + TierDefinition, + TierValidationTester, + TierValidationTester2, + ) - cls.loader.update_registry((TierValidationTester, TierValidationTester2)) + cls.loader.update_registry( + (TierValidationTester, TierValidationTester2, TierDefinition) + ) cls.test_model = cls.env[TierValidationTester._name] cls.test_model_2 = cls.env[TierValidationTester2._name] diff --git a/base_tier_validation/tests/tier_validation_tester.py b/base_tier_validation/tests/tier_validation_tester.py index e4e49a78a1..a291baffd1 100644 --- a/base_tier_validation/tests/tier_validation_tester.py +++ b/base_tier_validation/tests/tier_validation_tester.py @@ -1,7 +1,7 @@ # Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models +from odoo import api, fields, models class TierValidationTester(models.Model): @@ -44,3 +44,14 @@ class TierValidationTester2(models.Model): def action_confirm(self): self.write({"state": "confirmed"}) + + +class TierDefinition(models.Model): + _inherit = "tier.definition" + + @api.model + def _get_tier_validation_model_names(self): + res = super()._get_tier_validation_model_names() + res.append("tier.validation.tester") + res.append("tier.validation.tester2") + return res From effe0611e1270d506c1b38f35c1a33f07713fd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Tue, 24 Oct 2023 09:02:04 +0200 Subject: [PATCH 3/3] [FIX] base_tier_validation_forward: Import TierDefinition in tests to avoid errors TT33369 --- base_tier_validation_forward/tests/test_tier_validation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base_tier_validation_forward/tests/test_tier_validation.py b/base_tier_validation_forward/tests/test_tier_validation.py index 5215c3fce8..abe1e0627b 100644 --- a/base_tier_validation_forward/tests/test_tier_validation.py +++ b/base_tier_validation_forward/tests/test_tier_validation.py @@ -16,10 +16,14 @@ def setUpClass(cls): cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() from odoo.addons.base_tier_validation.tests.tier_validation_tester import ( + TierDefinition, TierValidationTester, + TierValidationTester2, ) - cls.loader.update_registry((TierValidationTester,)) + cls.loader.update_registry( + (TierValidationTester, TierValidationTester2, TierDefinition) + ) cls.test_model = cls.env[TierValidationTester._name] cls.tester_model = cls.env["ir.model"].search(