Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0] [MIG] fieldservice_stage_validation #603

Merged
merged 8 commits into from
Nov 30, 2020
Merged
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
113 changes: 113 additions & 0 deletions fieldservice_stage_validation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
====================
FSM Stage Validation
====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/12.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-12-0/field-service-12-0-fieldservice_stage_validation
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/264/12.0
:alt: Try me on Runbot

|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 <https://github.com/OCA/field-service/issues/1>`_.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/field-service/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_stage_validation%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Brian McMaster

Contributors
~~~~~~~~~~~~

* Brian McMaster <brian@mcmpest.com>

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-brian10048| |maintainer-max3903|

This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/12.0/fieldservice_stage_validation>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions fieldservice_stage_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2020 Brian McMaster <brian@mcmpest.com>
from . import models
15 changes: 15 additions & 0 deletions fieldservice_stage_validation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2020 Brian McMaster <brian@mcmpest.com>
# 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": "13.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"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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"
"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
#: code:addons/fieldservice_stage_validation/models/fsm_equipment.py:22
#: code:addons/fieldservice_stage_validation/models/fsm_location.py:22
#: code:addons/fieldservice_stage_validation/models/fsm_order.py:22
#: code:addons/fieldservice_stage_validation/models/fsm_person.py:22
#, python-format
msgid "Cannot move to stage \"%s\" until the \"%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 ""

73 changes: 73 additions & 0 deletions fieldservice_stage_validation/i18n/pt_PT.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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 <dgreis@sapo.pt>\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
#: code:addons/fieldservice_stage_validation/models/fsm_equipment.py:22
#: code:addons/fieldservice_stage_validation/models/fsm_location.py:22
#: code:addons/fieldservice_stage_validation/models/fsm_order.py:22
#: code:addons/fieldservice_stage_validation/models/fsm_person.py:22
#, 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."

#. 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"
9 changes: 9 additions & 0 deletions fieldservice_stage_validation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (C) 2020 Brian McMaster <brian@mcmpest.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import (
fsm_stage,
fsm_order,
fsm_equipment,
fsm_location,
fsm_person,
)
25 changes: 25 additions & 0 deletions fieldservice_stage_validation/models/fsm_equipment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2020 Brian McMaster <brian@mcmpest.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, models
from odoo.exceptions import ValidationError


class FSMEquipment(models.Model):
_inherit = "fsm.equipment"

@api.constrains("stage_id")
def _validate_stage_fields(self):
for rec in self:
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 "%s" '
'until the "%s" field is set.' % (stage.name, name)
)
)
25 changes: 25 additions & 0 deletions fieldservice_stage_validation/models/fsm_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2020 Brian McMaster <brian@mcmpest.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, models
from odoo.exceptions import ValidationError


class FSMLocation(models.Model):
_inherit = "fsm.location"

@api.constrains("stage_id")
def _validate_stage_fields(self):
for rec in self:
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 "%s" '
'until the "%s" field is set.' % (stage.name, name)
)
)
25 changes: 25 additions & 0 deletions fieldservice_stage_validation/models/fsm_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2020 Brian McMaster <brian@mcmpest.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, models
from odoo.exceptions import ValidationError


class FSMOrder(models.Model):
_inherit = "fsm.order"

@api.constrains("stage_id")
def _validate_stage_fields(self):
for rec in self:
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 "%s" '
'until the "%s" field is set.' % (stage.name, name)
)
)
25 changes: 25 additions & 0 deletions fieldservice_stage_validation/models/fsm_person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2020 Brian McMaster <brian@mcmpest.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, models
from odoo.exceptions import ValidationError


class FSMPerson(models.Model):
_inherit = "fsm.person"

@api.constrains("stage_id")
def _validate_stage_fields(self):
for rec in self:
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 "%s" '
'until the "%s" field is set.' % (stage.name, name)
)
)
Loading