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

[17.0] [MIG] helpdesk_mgmt_stage_validation: Migration to 17.0 #661

Open
wants to merge 3 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions helpdesk_mgmt_stage_validation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
================================
Helpdesk Ticket Stage Validation
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5d936cd9571b9a6a9218317dcc9a8d0ccf0aa6cf87060637d02109f2abb9319b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fhelpdesk-lightgray.png?logo=github
:target: https://github.com/OCA/helpdesk/tree/17.0/helpdesk_mgmt_stage_validation
:alt: OCA/helpdesk
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/helpdesk-17-0/helpdesk-17-0-helpdesk_mgmt_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/helpdesk&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

As the stage of a helpdesk ticket document progresses, it may be
important for specific fields of the document be completed.

For example, when a helpdesk ticket 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 helpdesk ticket, workers, locations, or equipments, this logic is
available to be applied to each document type.

**Table of contents**

.. contents::
:local:

Configuration
=============

- Go to Helpdesk > 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.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/helpdesk/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 <https://github.com/OCA/helpdesk/issues/new?body=module:%20helpdesk_mgmt_stage_validation%0Aversion:%2017.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
-------

* Camptocamp

Contributors
------------

- Bojan Anchev <[email protected]>

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.

This module is part of the `OCA/helpdesk <https://github.com/OCA/helpdesk/tree/17.0/helpdesk_mgmt_stage_validation>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions helpdesk_mgmt_stage_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions helpdesk_mgmt_stage_validation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Helpdesk Ticket Stage Validation",
"summary": "Validate input data when reaching a Helpdesk Ticket stage",
"version": "17.0.1.0.0",
"category": "After-Sales",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/helpdesk",
"depends": ["helpdesk_mgmt"],
"data": ["views/helpdesk_ticket_stage.xml"],
"license": "AGPL-3",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * helpdesk_mgmt_stage_validation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket__display_name
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage__display_name
msgid "Display Name"
msgstr ""

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage__validate_field_ids
msgid "Fields to Validate"
msgstr ""

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model,name:helpdesk_mgmt_stage_validation.model_helpdesk_ticket
msgid "Helpdesk Ticket"
msgstr ""

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model,name:helpdesk_mgmt_stage_validation.model_helpdesk_ticket_stage
msgid "Helpdesk Ticket Stage"
msgstr ""

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket__id
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage__id
msgid "ID"
msgstr ""

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket____last_update
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage____last_update
msgid "Last Modified on"
msgstr ""

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,help:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage__validate_field_ids
msgid "Select fields which must be set on the document in this stage"
msgstr ""

#. module: helpdesk_mgmt_stage_validation
#: code:addons/helpdesk_mgmt_stage_validation/models/helpdesk_ticket.py:0
#: code:addons/helpdesk_mgmt_stage_validation/tests/test_helpdesk_ticket_stage_validation.py:0
#, python-format
msgid ""
"Ticket %(ticket)s can't be moved to the stage %(stage)s until the following "
"fields are set: %(fields)s."
msgstr ""
67 changes: 67 additions & 0 deletions helpdesk_mgmt_stage_validation/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * helpdesk_mgmt_stage_validation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-04-29 16:35+0000\n"
"Last-Translator: mymage <[email protected]>\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: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket__display_name
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage__validate_field_ids
msgid "Fields to Validate"
msgstr "Campi da validare"

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model,name:helpdesk_mgmt_stage_validation.model_helpdesk_ticket
msgid "Helpdesk Ticket"
msgstr "Ticket assistenza clienti"

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model,name:helpdesk_mgmt_stage_validation.model_helpdesk_ticket_stage
msgid "Helpdesk Ticket Stage"
msgstr "Fase ticket assistenza clienti"

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket__id
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage__id
msgid "ID"
msgstr "ID"

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket____last_update
#: model:ir.model.fields,field_description:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_stage____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: helpdesk_mgmt_stage_validation
#: model:ir.model.fields,help:helpdesk_mgmt_stage_validation.field_helpdesk_ticket_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: helpdesk_mgmt_stage_validation
#: code:addons/helpdesk_mgmt_stage_validation/models/helpdesk_ticket.py:0
#: code:addons/helpdesk_mgmt_stage_validation/tests/test_helpdesk_ticket_stage_validation.py:0
#, python-format
msgid ""
"Ticket %(ticket)s can't be moved to the stage %(stage)s until the following "
"fields are set: %(fields)s."
msgstr ""
"Il ticket %(ticket)s non può essere spostato alla fase %(stage)s finché i "
"seguenti campi non sono impostati: %(fields)s."
6 changes: 6 additions & 0 deletions helpdesk_mgmt_stage_validation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import (
helpdesk_ticket,
helpdesk_ticket_stage,
)
44 changes: 44 additions & 0 deletions helpdesk_mgmt_stage_validation/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, models
from odoo.exceptions import ValidationError


class HelpdeskTicket(models.Model):
_inherit = "helpdesk.ticket"

def _check_ticket_has_empty_fields(self):
self.ensure_one()
error_message = False
field_ids = self.stage_id.validate_field_ids
field_names = [x.name for x in field_ids]
values = self.read(field_names)
fields = [
field.field_description for field in field_ids if not values[0][field.name]
]
fields = ", ".join(fields)
if fields:
error_message = _(
"Ticket %(ticket)s can't be moved to the stage %(stage)s until "
"the following fields are set: %(fields)s.",
ticket=self.name,
stage=self.stage_id.name,
fields=fields,
)
return error_message

def _validate_stage_fields_error_message(self):
error_message = []
for record in self:
message = record._check_ticket_has_empty_fields()
if message:
error_message.append(message)
return error_message

@api.constrains("stage_id")
def _validate_stage_fields(self):
message = self._validate_stage_fields_error_message()
if message:
message = "\n".join(message)
raise ValidationError(message)
15 changes: 15 additions & 0 deletions helpdesk_mgmt_stage_validation/models/helpdesk_ticket_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class HelpdeskTicketStage(models.Model):
_inherit = "helpdesk.ticket.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",
domain=[("model", "=", "helpdesk.ticket")],
)
3 changes: 3 additions & 0 deletions helpdesk_mgmt_stage_validation/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions helpdesk_mgmt_stage_validation/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Go to Helpdesk \> Configuration \> Stages
- Create or select a stage
- Select one or more fields to be validated
1 change: 1 addition & 0 deletions helpdesk_mgmt_stage_validation/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Bojan Anchev \<<[email protected]>\>
10 changes: 10 additions & 0 deletions helpdesk_mgmt_stage_validation/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
As the stage of a helpdesk ticket document progresses, it may be
important for specific fields of the document be completed.

For example, when a helpdesk ticket 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 helpdesk ticket, workers, locations, or equipments, this logic is
available to be applied to each document type.
3 changes: 3 additions & 0 deletions helpdesk_mgmt_stage_validation/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading