-
-
Notifications
You must be signed in to change notification settings - Fork 326
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 #655
Open
yankinmax
wants to merge
8
commits into
OCA:17.0
Choose a base branch
from
yankinmax:17.0-mig-helpdesk_mgmt_stage_validation
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2e036db
[14.0][ADD] Helpdesk Stage Validation
BojanOD e4e3ab6
[UPD] Update helpdesk_mgmt_stage_validation.pot
3f46227
[BOT] post-merge updates
OCA-git-bot 7ed42e7
Added translation using Weblate (Italian)
mymage 2bdc345
Translated using Weblate (Italian)
mymage d5f59af
[IMP] helpdesk_mgmt_stage_validation: pre-commit auto fixes
yankinmax 7758ba0
[MIG] helpdesk_mgmt_stage_validation: Migration to 17.0
yankinmax f126de3
add test-requirements
yankinmax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
} |
61 changes: 61 additions & 0 deletions
61
helpdesk_mgmt_stage_validation/i18n/helpdesk_mgmt_stage_validation.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %s can't be moved to the stage %s until the following fields are set:" | ||
" %s." | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %s can't be moved to the stage %s until the following fields are set:" | ||
" %s." | ||
msgstr "" | ||
"Il ticket %s non può essere spostato alla fase %s finché i sequenti campi " | ||
"non sono impostati: %s." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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 = _( | ||
f"Ticket {self.name} can't be moved to the stage " | ||
f"{self.stage_id.name} until the following fields are set: {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
15
helpdesk_mgmt_stage_validation/models/helpdesk_ticket_stage.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")]', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Bojan Anchev \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct. If you use an f-string, it will be substituted before calling gettext translation, and so the translation won't work.
The previous implementation was ok, could you revert it?