diff --git a/fieldservice_stage_validation/README.rst b/fieldservice_stage_validation/README.rst new file mode 100644 index 0000000000..5d03a71cc1 --- /dev/null +++ b/fieldservice_stage_validation/README.rst @@ -0,0 +1,119 @@ +==================== +FSM Stage Validation +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:1ced40d5e26a6495ac55732e9d6ba749aa76729869fa24363ba8b7d8ccaa03b1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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%2Ffield--service-lightgray.png?logo=github + :target: https://github.com/OCA/field-service/tree/17.0/fieldservice_stage_validation + :alt: OCA/field-service +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/field-service-17-0/field-service-17-0-fieldservice_stage_validation + :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/field-service&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +As the stage of a field service document progresses, it may be important +for specific fields of the document be completed. + +For example, when a field service order enters the 'Complete' stage, the +fields for 'Actual End Date' and/or 'Resolution Notes' should be set. + +This module allows you to raise a Validation Error if the designated +fields are not set when moving to a new stage. Since stages can be used +for field service orders, workers, locations, or equipments, this logic +is available to be applied to each document type. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +- Go to Field Service > Configuration > Stages +- Create or select a stage +- Select one or more fields to be validated + +Usage +===== + +- Follow steps outlined in Configuration. +- User will receive validation error if a field is not set when + attempting to move to a new stage. + +Known issues / Roadmap +====================== + +The roadmap of the Field Service application is documented on +`Github `__. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Brian McMaster + +Contributors +------------ + +- Brian McMaster +- `APSL `__: + + - Antoni Marroig + +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. + +.. |maintainer-brian10048| image:: https://github.com/brian10048.png?size=40px + :target: https://github.com/brian10048 + :alt: brian10048 +.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainers `__: + +|maintainer-brian10048| |maintainer-max3903| + +This module is part of the `OCA/field-service `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fieldservice_stage_validation/__init__.py b/fieldservice_stage_validation/__init__.py new file mode 100644 index 0000000000..2acc0e96c4 --- /dev/null +++ b/fieldservice_stage_validation/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2020 Brian McMaster +from . import models diff --git a/fieldservice_stage_validation/__manifest__.py b/fieldservice_stage_validation/__manifest__.py new file mode 100644 index 0000000000..80682da19a --- /dev/null +++ b/fieldservice_stage_validation/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright (C) 2020 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "FSM Stage Validation", + "summary": "Validate input data when reaching a Field Service stage", + "version": "18.0.1.0.0", + "category": "Field Service", + "author": "Brian McMaster, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/field-service", + "depends": ["fieldservice"], + "data": ["views/fsm_stage.xml"], + "license": "AGPL-3", + "development_status": "Beta", + "maintainers": ["brian10048", "max3903"], +} diff --git a/fieldservice_stage_validation/i18n/es.po b/fieldservice_stage_validation/i18n/es.po new file mode 100644 index 0000000000..82af49b2f7 --- /dev/null +++ b/fieldservice_stage_validation/i18n/es.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-04-19 06:49+0000\n" +"PO-Revision-Date: 2024-04-19 06:49+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "Cannot move to stage %(stage_name)s until the %(name)s field is set." +msgstr "No se puede mover al escenario %(stage_name)s hasta que se establezca el campo %(name)s." + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Equipo de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "Ubicación de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "Pedido de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "Etapa de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "Trabajador de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "Campos a Validar" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "Modelo para la Etapa" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "Seleccione los campos que se deben establecer en el documento en esta etapa" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "Campo técnico para mantener el tipo del modelo" diff --git a/fieldservice_stage_validation/i18n/es_AR.po b/fieldservice_stage_validation/i18n/es_AR.po new file mode 100644 index 0000000000..1daab20fdf --- /dev/null +++ b/fieldservice_stage_validation/i18n/es_AR.po @@ -0,0 +1,79 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-11-12 04:46+0000\n" +"Last-Translator: Ignacio Buioli \n" +"Language-Team: none\n" +"Language: es_AR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "" +"Cannot move to stage \"%(stage_name)s\" until the \"%(name)s\" field is set." +msgstr "" +"No se puede mover al escenario \"%(stage_name)s\" hasta que se establezca el " +"campo \"%(name)s\"." + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Equipo de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "Ubicación del Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "Pedido de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "Etapa de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "Trabajador de Servicio de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "Campos a Validar" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "Modelo para la Etapa" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "" +"Seleccione los campos que se deben establecer en el documento en esta etapa" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "Campo técnico para mantener el tipo del modelo" + +#, python-format +#~ msgid "Cannot move to stage \"%s\" until the \"%s\" field is set." +#~ msgstr "" +#~ "No se puede mover a la etapa \"%s\" hasta que se establezca el campo \"%s" +#~ "\"." diff --git a/fieldservice_stage_validation/i18n/fieldservice_stage_validation.pot b/fieldservice_stage_validation/i18n/fieldservice_stage_validation.pot new file mode 100644 index 0000000000..6e2c1f5e93 --- /dev/null +++ b/fieldservice_stage_validation/i18n/fieldservice_stage_validation.pot @@ -0,0 +1,66 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "Cannot move to stage %(stage_name)s until the %(name)s field is set." +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "" diff --git a/fieldservice_stage_validation/i18n/fr_FR.po b/fieldservice_stage_validation/i18n/fr_FR.po new file mode 100644 index 0000000000..8ee064f81b --- /dev/null +++ b/fieldservice_stage_validation/i18n/fr_FR.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-05-20 10:48+0000\n" +"Last-Translator: Sandrine (ACSONE) \n" +"Language-Team: none\n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "" +"Cannot move to stage \"%(stage_name)s\" until the \"%(name)s\" field is set." +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Equipement Service sur site" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "Lieu du service sur site" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "Service sur site" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "Etape du service sur site" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "Travailleur du service sur site" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "Champs à valider" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "Modèle pour l'étape" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "" +"Sélectionnez les champs qui doivent être remplis sur le document à cette " +"étape" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "Champ technique pour contenir le type de modèle" + +#, python-format +#~ msgid "Cannot move to stage \"%s\" until the \"%s\" field is set." +#~ msgstr "Le champ \"%s\" doit être rempli pour passer à l'étape \"%s\"." diff --git a/fieldservice_stage_validation/i18n/it.po b/fieldservice_stage_validation/i18n/it.po new file mode 100644 index 0000000000..1d72aeb2e0 --- /dev/null +++ b/fieldservice_stage_validation/i18n/it.po @@ -0,0 +1,79 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-29 14:35+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "" +"Cannot move to stage \"%(stage_name)s\" until the \"%(name)s\" field is set." +msgstr "" +"Non si può passare allo stato \"%(stage_name)s\" finché il campo \"%(name)s" +"\" non è compilato." + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Attrezzatura assistenza sul campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "Località assistenza sul campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "Ordine assistenza sul campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "Fase assistenza sul campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "Lavoratore assistenza sul campo" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "Campi da validare" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "Modello per fase" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "" +"Selezionare i campi che devono essere compilati nel documento in questa fase" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "Campo tecnico per memorizzare il tipo modello" + +#, python-format +#~ msgid "Cannot move to stage \"%s\" until the \"%s\" field is set." +#~ msgstr "" +#~ "Non si può passare alla fase \"%s\" finché il campo \"%s\" non è " +#~ "impostato." diff --git a/fieldservice_stage_validation/i18n/pt_BR.po b/fieldservice_stage_validation/i18n/pt_BR.po new file mode 100644 index 0000000000..1a25597618 --- /dev/null +++ b/fieldservice_stage_validation/i18n/pt_BR.po @@ -0,0 +1,72 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-08-11 23:13+0000\n" +"Last-Translator: Adriano Prado \n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "" +"Cannot move to stage \"%(stage_name)s\" until the \"%(name)s\" field is set." +msgstr "" +"Não é possível mover para o estágio \"%(stage_name)s\" até que o campo " +"\"%(name)s\" seja definido." + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Equipamento de Serviço de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "Localização do Serviço de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "Ordem de Serviço de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "Estágio de Serviço de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "Trabalhador do Serviço de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "Campos para Validar" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "Modelo par Estagio" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "Selecione os campos que devem ser definidos no documento nesta etapa" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "Campo técnico para manter o tipo de modelo" diff --git a/fieldservice_stage_validation/i18n/pt_PT.po b/fieldservice_stage_validation/i18n/pt_PT.po new file mode 100644 index 0000000000..6cdb7432c7 --- /dev/null +++ b/fieldservice_stage_validation/i18n/pt_PT.po @@ -0,0 +1,77 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-02 00:19+0000\n" +"Last-Translator: Daniel Reis \n" +"Language-Team: none\n" +"Language: pt_PT\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "" +"Cannot move to stage \"%(stage_name)s\" until the \"%(name)s\" field is set." +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Equipamento de Servi??o de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "Localiza????o de Servi??o de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "Ordem de Servi??o de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "Etapa de Servi??o de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "Trabalhador de Servi??o de Campo" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "Campos a Validar" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "Modelo para Etapa" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "" +"Selecione os campos que devem estar preenchidos no documento nesta Etapa" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "Campo t??cnico para o tipo de modelo" + +#, python-format +#~ msgid "Cannot move to stage \"%s\" until the \"%s\" field is set." +#~ msgstr "" +#~ "N??o pode mudar para etapa \"%s\" enquanto o campo \"%s\" n??o for " +#~ "definido." diff --git a/fieldservice_stage_validation/i18n/tr.po b/fieldservice_stage_validation/i18n/tr.po new file mode 100644 index 0000000000..bc1ad1aac5 --- /dev/null +++ b/fieldservice_stage_validation/i18n/tr.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stage_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: fieldservice_stage_validation +#. odoo-python +#: code:addons/fieldservice_stage_validation/models/validate_utils.py:0 +#, python-format +msgid "" +"Cannot move to stage \"%(stage_name)s\" until the \"%(name)s\" field is set." +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_location +msgid "Field Service Location" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_order +msgid "Field Service Order" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_stage +msgid "Field Service Stage" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model,name:fieldservice_stage_validation.model_fsm_person +msgid "Field Service Worker" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Fields to Validate" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,field_description:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Model for Stage" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__validate_field_ids +msgid "Select fields which must be set on the document in this stage" +msgstr "" + +#. module: fieldservice_stage_validation +#: model:ir.model.fields,help:fieldservice_stage_validation.field_fsm_stage__stage_type_model_id +msgid "Technical field to hold model type" +msgstr "" diff --git a/fieldservice_stage_validation/models/__init__.py b/fieldservice_stage_validation/models/__init__.py new file mode 100644 index 0000000000..07646a0e36 --- /dev/null +++ b/fieldservice_stage_validation/models/__init__.py @@ -0,0 +1,10 @@ +# Copyright (C) 2020 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import ( + fsm_stage, + fsm_order, + fsm_equipment, + fsm_location, + fsm_person, + validate_utils, +) diff --git a/fieldservice_stage_validation/models/fsm_equipment.py b/fieldservice_stage_validation/models/fsm_equipment.py new file mode 100644 index 0000000000..38a699534a --- /dev/null +++ b/fieldservice_stage_validation/models/fsm_equipment.py @@ -0,0 +1,13 @@ +# Copyright (C) 2020 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, models + +from .validate_utils import validate_stage_fields + + +class FSMEquipment(models.Model): + _inherit = "fsm.equipment" + + @api.constrains("stage_id") + def _validate_stage_fields(self): + validate_stage_fields(self) diff --git a/fieldservice_stage_validation/models/fsm_location.py b/fieldservice_stage_validation/models/fsm_location.py new file mode 100644 index 0000000000..9e535f1d5a --- /dev/null +++ b/fieldservice_stage_validation/models/fsm_location.py @@ -0,0 +1,13 @@ +# Copyright (C) 2020 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, models + +from .validate_utils import validate_stage_fields + + +class FSMLocation(models.Model): + _inherit = "fsm.location" + + @api.constrains("stage_id") + def _validate_stage_fields(self): + validate_stage_fields(self) diff --git a/fieldservice_stage_validation/models/fsm_order.py b/fieldservice_stage_validation/models/fsm_order.py new file mode 100644 index 0000000000..34639ed878 --- /dev/null +++ b/fieldservice_stage_validation/models/fsm_order.py @@ -0,0 +1,13 @@ +# Copyright (C) 2020 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, models + +from .validate_utils import validate_stage_fields + + +class FSMOrder(models.Model): + _inherit = "fsm.order" + + @api.constrains("stage_id") + def _validate_stage_fields(self): + validate_stage_fields(self) diff --git a/fieldservice_stage_validation/models/fsm_person.py b/fieldservice_stage_validation/models/fsm_person.py new file mode 100644 index 0000000000..893d68e4bf --- /dev/null +++ b/fieldservice_stage_validation/models/fsm_person.py @@ -0,0 +1,13 @@ +# Copyright (C) 2020 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, models + +from .validate_utils import validate_stage_fields + + +class FSMPerson(models.Model): + _inherit = "fsm.person" + + @api.constrains("stage_id") + def _validate_stage_fields(self): + validate_stage_fields(self) diff --git a/fieldservice_stage_validation/models/fsm_stage.py b/fieldservice_stage_validation/models/fsm_stage.py new file mode 100644 index 0000000000..5063f41880 --- /dev/null +++ b/fieldservice_stage_validation/models/fsm_stage.py @@ -0,0 +1,30 @@ +# Copyright (C) 2020 Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class FSMStage(models.Model): + _inherit = "fsm.stage" + + validate_field_ids = fields.Many2many( + "ir.model.fields", + string="Fields to Validate", + help="Select fields which must be set on the document in this stage", + ) + + stage_type_model_id = fields.Many2one( + "ir.model", + compute="_compute_stage_model", + string="Model for Stage", + help="Technical field to hold model type", + ) + + @api.depends("stage_type") + def _compute_stage_model(self): + Model = self.env["ir.model"] + for rec in self: + model_id = False + if rec.stage_type: + model_string = "fsm." + rec.stage_type + model_id = Model.search([("model", "=", model_string)], limit=1).id + rec.stage_type_model_id = model_id diff --git a/fieldservice_stage_validation/models/validate_utils.py b/fieldservice_stage_validation/models/validate_utils.py new file mode 100644 index 0000000000..04894793e2 --- /dev/null +++ b/fieldservice_stage_validation/models/validate_utils.py @@ -0,0 +1,24 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import _ +from odoo.exceptions import ValidationError + + +def validate_stage_fields(records): + for rec in records: + stage = rec.stage_id + field_ids = stage.validate_field_ids + field_names = [x.name for x in field_ids] + values = rec.read(field_names) + + for name in field_names: + if not values[0][name]: + raise ValidationError( + _( + "Cannot move to stage %(stage_name)s " + "until the %(name)s field is set.", + stage_name=stage.name, + name=name, + ) + ) diff --git a/fieldservice_stage_validation/pyproject.toml b/fieldservice_stage_validation/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/fieldservice_stage_validation/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/fieldservice_stage_validation/readme/CONFIGURE.md b/fieldservice_stage_validation/readme/CONFIGURE.md new file mode 100644 index 0000000000..15d0713eb7 --- /dev/null +++ b/fieldservice_stage_validation/readme/CONFIGURE.md @@ -0,0 +1,3 @@ +- Go to Field Service \> Configuration \> Stages +- Create or select a stage +- Select one or more fields to be validated diff --git a/fieldservice_stage_validation/readme/CONTRIBUTORS.md b/fieldservice_stage_validation/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..31661d9190 --- /dev/null +++ b/fieldservice_stage_validation/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Brian McMaster \<\> +- [APSL](https://apsl.tech): + - Antoni Marroig \<\> diff --git a/fieldservice_stage_validation/readme/DESCRIPTION.md b/fieldservice_stage_validation/readme/DESCRIPTION.md new file mode 100644 index 0000000000..f41a35bb7e --- /dev/null +++ b/fieldservice_stage_validation/readme/DESCRIPTION.md @@ -0,0 +1,10 @@ +As the stage of a field service document progresses, it may be important +for specific fields of the document be completed. + +For example, when a field service order enters the 'Complete' stage, the +fields for 'Actual End Date' and/or 'Resolution Notes' should be set. + +This module allows you to raise a Validation Error if the designated +fields are not set when moving to a new stage. Since stages can be used +for field service orders, workers, locations, or equipments, this logic +is available to be applied to each document type. diff --git a/fieldservice_stage_validation/readme/ROADMAP.md b/fieldservice_stage_validation/readme/ROADMAP.md new file mode 100644 index 0000000000..e14dbdee6f --- /dev/null +++ b/fieldservice_stage_validation/readme/ROADMAP.md @@ -0,0 +1,2 @@ +The roadmap of the Field Service application is documented on +[Github](https://github.com/OCA/field-service/issues/1). diff --git a/fieldservice_stage_validation/readme/USAGE.md b/fieldservice_stage_validation/readme/USAGE.md new file mode 100644 index 0000000000..c92d6ab280 --- /dev/null +++ b/fieldservice_stage_validation/readme/USAGE.md @@ -0,0 +1,3 @@ +- Follow steps outlined in Configuration. +- User will receive validation error if a field is not set when + attempting to move to a new stage. diff --git a/fieldservice_stage_validation/static/description/icon.png b/fieldservice_stage_validation/static/description/icon.png new file mode 100644 index 0000000000..955674d8f0 Binary files /dev/null and b/fieldservice_stage_validation/static/description/icon.png differ diff --git a/fieldservice_stage_validation/static/description/index.html b/fieldservice_stage_validation/static/description/index.html new file mode 100644 index 0000000000..9a7ff5ae10 --- /dev/null +++ b/fieldservice_stage_validation/static/description/index.html @@ -0,0 +1,457 @@ + + + + + +FSM Stage Validation + + + +
+

FSM Stage Validation

+ + +

Beta License: AGPL-3 OCA/field-service Translate me on Weblate Try me on Runboat

+

As the stage of a field service document progresses, it may be important +for specific fields of the document be completed.

+

For example, when a field service order enters the ‘Complete’ stage, the +fields for ‘Actual End Date’ and/or ‘Resolution Notes’ should be set.

+

This module allows you to raise a Validation Error if the designated +fields are not set when moving to a new stage. Since stages can be used +for field service orders, workers, locations, or equipments, this logic +is available to be applied to each document type.

+

Table of contents

+ +
+

Configuration

+
    +
  • Go to Field Service > Configuration > Stages
  • +
  • Create or select a stage
  • +
  • Select one or more fields to be validated
  • +
+
+
+

Usage

+
    +
  • Follow steps outlined in Configuration.
  • +
  • User will receive validation error if a field is not set when +attempting to move to a new stage.
  • +
+
+
+

Known issues / Roadmap

+

The roadmap of the Field Service application is documented on +Github.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Brian McMaster
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainers:

+

brian10048 max3903

+

This module is part of the OCA/field-service project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/fieldservice_stage_validation/tests/__init__.py b/fieldservice_stage_validation/tests/__init__.py new file mode 100644 index 0000000000..7586a16155 --- /dev/null +++ b/fieldservice_stage_validation/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2020, Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_fsm_stage_validation diff --git a/fieldservice_stage_validation/tests/test_fsm_stage_validation.py b/fieldservice_stage_validation/tests/test_fsm_stage_validation.py new file mode 100644 index 0000000000..d9605c71ea --- /dev/null +++ b/fieldservice_stage_validation/tests/test_fsm_stage_validation.py @@ -0,0 +1,200 @@ +# Copyright 2020, Brian McMaster +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import fields +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase + + +class TestFSMStageValidation(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.stage = cls.env["fsm.stage"] + cls.fsm_order = cls.env["fsm.order"] + cls.fsm_person = cls.env["fsm.person"] + cls.fsm_location = cls.env["fsm.location"] + cls.fsm_equipment = cls.env["fsm.equipment"] + cls.ir_model_fields = cls.env["ir.model.fields"] + + # Get some fields to use in the stages + cls.order_field = cls.ir_model_fields.search( + [("model", "=", "fsm.order"), ("name", "=", "description")] + ) + cls.person_field = cls.ir_model_fields.search( + [("model", "=", "fsm.person"), ("name", "=", "mobile")] + ) + cls.location_field = cls.ir_model_fields.search( + [("model", "=", "fsm.location"), ("name", "=", "direction")] + ) + cls.equipment_field = cls.ir_model_fields.search( + [("model", "=", "fsm.equipment"), ("name", "=", "notes")] + ) + + # For each model type, create a default stage and a stage + # which will apply field validation + # Order Stages + cls.stage_order_default = cls.stage.create( + { + "name": "Order Stage Default", + "stage_type": "order", + "is_default": True, + "sequence": "10", + } + ) + cls.stage_order = cls.stage.create( + { + "name": "Order Stage Validate", + "stage_type": "order", + "validate_field_ids": [(6, 0, [cls.order_field.id])], + "sequence": "11", + } + ) + # Person Stages + cls.stage_person_default = cls.stage.create( + { + "name": "Person Stage Default", + "stage_type": "worker", + "is_default": True, + "sequence": "10", + } + ) + cls.stage_person = cls.stage.create( + { + "name": "Person Stage Validate", + "stage_type": "worker", + "validate_field_ids": [(6, 0, [cls.person_field.id])], + "sequence": "11", + } + ) + # Location Stages + cls.stage_location_default = cls.stage.create( + { + "name": "Location Stage Default", + "stage_type": "location", + "is_default": True, + "sequence": "10", + } + ) + cls.stage_location = cls.stage.create( + { + "name": "Location Stage Validate", + "stage_type": "location", + "validate_field_ids": [(6, 0, [cls.location_field.id])], + "sequence": "11", + } + ) + # Equipment Stages + cls.stage_equipment_default = cls.stage.create( + { + "name": "Equipment Stage Default", + "stage_type": "equipment", + "is_default": True, + "sequence": "10", + } + ) + cls.stage_equipment = cls.stage.create( + { + "name": "Equipment Stage Validate", + "stage_type": "equipment", + "validate_field_ids": [(6, 0, [cls.equipment_field.id])], + "sequence": "11", + } + ) + + # Create a person + cls.person_01 = cls.fsm_person.create( + { + "name": "FSM Worker 01", + "partner_id": cls.env["res.partner"] + .create({"name": "Worker 01 Partner"}) + .id, + "stage_id": cls.stage_person_default.id, + } + ) + # Create a location + cls.location_01 = cls.fsm_location.create( + { + "name": "Location 01", + "owner_id": cls.env["res.partner"] + .create({"name": "Location 01 Partner"}) + .id, + "stage_id": cls.stage_location_default.id, + } + ) + # Create an Equipment + cls.equipment_01 = cls.fsm_equipment.create( + { + "name": "Equipment 01", + "current_location_id": cls.location_01.id, + "stage_id": cls.stage_equipment_default.id, + } + ) + # Create an Order + cls.order_01 = cls.fsm_order.create({"location_id": cls.location_01.id}) + + def get_validate_message(self, stage): + stage_name = stage.name + field_name = fields.first(stage.validate_field_ids).name + return f"Cannot move to stage {stage_name} until the {field_name} field is set." + + def test_fsm_stage_validation(self): + # Validate the stage computes the correct model type + self.assertEqual( + self.stage_order.stage_type_model_id, + self.env["ir.model"].search([("model", "=", "fsm.order")]), + "FSM Stage model is not computed correctly", + ) + validate_message = self.get_validate_message(self.stage_equipment) + # Validate the Equipment cannot move to next stage + with self.assertRaisesRegex(ValidationError, validate_message): + self.equipment_01.next_stage() + + # Update the Equipment notes field and validate it goes to next stage + self.equipment_01.notes = "Equipment service note" + self.equipment_01.next_stage() + self.assertEqual( + self.equipment_01.stage_id, + self.stage_equipment, + "FSM Equipment did not progress to correct stage", + ) + validate_message = self.get_validate_message(self.stage_location) + # Validate the Location cannot move to next stage + with self.assertRaisesRegex(ValidationError, validate_message): + self.location_01.next_stage() + + # Update the Location directions field and validate it goes to next stage + self.location_01.direction = "Location direction note" + self.location_01.next_stage() + self.assertEqual( + self.location_01.stage_id, + self.stage_location, + "FSM Location did not progress to correct stage", + ) + validate_message = self.get_validate_message(self.stage_person) + # Validate the Person cannot move to next stage + with self.assertRaisesRegex(ValidationError, validate_message): + self.person_01.next_stage() + + # Update the Person mobile field and validate it goes to next stage + self.person_01.mobile = "1-888-888-8888" + self.person_01.next_stage() + self.assertEqual( + self.person_01.stage_id, + self.stage_person, + "FSM Person did not progress to correct stage", + ) + validate_message = self.get_validate_message(self.stage_order) + # Validate the Order cannot move to stage which requires validation + with self.assertRaisesRegex(ValidationError, validate_message): + self.order_01.write({"stage_id": self.stage_order.id}) + + # Update the Order description field and validate it goes to next stage + self.order_01.description = "Complete the work order" + self.order_01.write({"stage_id": self.stage_order.id}) + self.assertEqual( + self.order_01.stage_id, + self.stage_order, + "FSM Order did not progress to correct stage", + ) diff --git a/fieldservice_stage_validation/views/fsm_stage.xml b/fieldservice_stage_validation/views/fsm_stage.xml new file mode 100644 index 0000000000..adf924b01c --- /dev/null +++ b/fieldservice_stage_validation/views/fsm_stage.xml @@ -0,0 +1,18 @@ + + + + fsm.stage.validation.form + fsm.stage + + + + + + + + +