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 #655

Open
wants to merge 8 commits into
base: 17.0
Choose a base branch
from
Open
2 changes: 0 additions & 2 deletions helpdesk_mgmt_stage_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
2 changes: 1 addition & 1 deletion helpdesk_mgmt_stage_validation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Helpdesk Ticket Stage Validation",
"summary": "Validate input data when reaching a Helpdesk Ticket stage",
"version": "14.0.1.0.0",
"version": "17.0.1.0.0",
"category": "After-Sales",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/helpdesk",
Expand Down
6 changes: 3 additions & 3 deletions helpdesk_mgmt_stage_validation/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def _check_ticket_has_empty_fields(self):
fields = ", ".join(fields)
if fields:
error_message = _(
"Ticket %s can't be moved to the stage %s until "
"the following fields are set: %s."
) % (self.name, self.stage_id.name, fields)
f"Ticket {self.name} can't be moved to the stage "
f"{self.stage_id.name} until the following fields are set: {fields}."
)

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?

return error_message

def _validate_stage_fields_error_message(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

from odoo import _, fields
from odoo.exceptions import ValidationError
from odoo.tests import SavepointCase
from odoo.tests.common import TransactionCase

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT

class TestHelpdeskStageValidation(SavepointCase):

class TestHelpdeskStageValidation(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.env = cls.env["base"].with_context(**DISABLED_MAIL_CONTEXT).env
cls.stage = cls.env["helpdesk.ticket.stage"]
cls.helpdesk_ticket = cls.env["helpdesk.ticket"]
cls.ir_model_fields = cls.env["ir.model.fields"]
Expand Down Expand Up @@ -48,9 +50,9 @@ def get_validate_message(self, ticket, stage):
fields = ", ".join(fields)
if fields:
validate_message = _(
"Ticket %s can't be moved to the stage %s until "
"the following fields are set: %s."
) % (ticket.name, stage.name, fields)
f"Ticket {ticket.name} can't be moved to the stage "
f"{stage.name} until the following fields are set: {fields}."
)
return validate_message

def test_helpdesk_ticket_stage_validation(self):
Expand Down
Loading