Skip to content

Commit

Permalink
Merge PR #522 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jan 17, 2024
2 parents 31529bb + a7b0736 commit d45b96d
Show file tree
Hide file tree
Showing 24 changed files with 164 additions and 27 deletions.
3 changes: 2 additions & 1 deletion helpdesk_mgmt/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Helpdesk Management
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:37cc770b0537354407fedcbe0d568ba9bdd6aa460144a7af475c60ae3f91ad27
!! source digest: sha256:a417b3ef325ea73b03c6c64e0476702e5a35949224072491138ce827feb4d6e7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -214,6 +214,7 @@ Contributors

* Pedro M. Baeza
* Víctor Martínez
* Carolina Fernandez

* `ID42 Sistemas <https://www.id42.com.br>`_:

Expand Down
20 changes: 9 additions & 11 deletions helpdesk_mgmt/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,21 @@ def _prepare_submit_ticket_vals(self, **kw):
category = http.request.env["helpdesk.ticket.category"].browse(
int(kw.get("category"))
)
company = category.company_id or http.request.env.user.company_id
company = category.company_id or http.request.env.company
vals = {
"company_id": company.id,
"category_id": category.id,
"description": plaintext2html(kw.get("description")),
"name": kw.get("subject"),
"attachment_ids": False,
"channel_id": request.env["helpdesk.ticket.channel"]
.sudo()
.search([("name", "=", "Web")])
.id,
"channel_id": request.env.ref(
"helpdesk_mgmt.helpdesk_ticket_channel_web", False
).id,
"partner_id": request.env.user.partner_id.id,
"partner_name": request.env.user.partner_id.name,
"partner_email": request.env.user.partner_id.email,
# Need to set stage_id so that the _track_template() method is called
# and the mail is sent automatically if applicable
"stage_id": request.env["helpdesk.ticket"]
.with_company(company.id)
.default_get(["stage_id"])["stage_id"],
}
team = http.request.env["helpdesk.ticket.team"]
if company.helpdesk_mgmt_portal_select_team and kw.get("team"):
team = (
http.request.env["helpdesk.ticket.team"]
Expand All @@ -98,7 +93,10 @@ def _prepare_submit_ticket_vals(self, **kw):
[("id", "=", int(kw.get("team"))), ("show_in_portal", "=", True)]
)
)
vals.update({"team_id": team.id})
vals["team_id"] = team.id
# Need to set stage_id so that the _track_template() method is called
# and the mail is sent automatically if applicable
vals["stage_id"] = team._get_applicable_stages()[:1].id
return vals

@http.route("/submitted/ticket", type="http", auth="user", website=True, csrf=True)
Expand Down
4 changes: 2 additions & 2 deletions helpdesk_mgmt/controllers/myaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def portal_my_ticket(self, ticket_id, access_token=None, **kw):
return request.render("helpdesk_mgmt.portal_helpdesk_ticket_page", values)

def _ticket_get_page_view_values(self, ticket, access_token, **kwargs):
closed_stages = request.env["helpdesk.ticket.stage"].search(
[("close_from_portal", "=", True)]
closed_stages = ticket.team_id._get_applicable_stages().filtered(
lambda s: s.close_from_portal
)
values = {
"closed_stages": closed_stages, # used to display close buttons
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ msgstr "Helpdesk Teamsuche"
msgid "Helpdesk Team name..."
msgstr "Helpdesk Teamname..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/en_GB.po
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ msgstr ""
msgid "Helpdesk Team name..."
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,11 @@ msgstr "Buscar equipo del servicio de asistencia"
msgid "Helpdesk Team name..."
msgstr "Nombre del equipo..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr "Equipos del servicio de asistencia"

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/es_AR.po
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@ msgstr "Buscar Equipo de Mesa de Ayuda"
msgid "Helpdesk Team name..."
msgstr "Nombre del equipo..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr "Equipos de la Mesa de Ayuda"

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ msgstr "Recherche d'équipe d'assistance"
msgid "Helpdesk Team name..."
msgstr "Nom de l'équipe d'assistance ..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/helpdesk_mgmt.pot
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,11 @@ msgstr ""
msgid "Helpdesk Team name..."
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/hu.po
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,11 @@ msgstr "Csapat keresés"
msgid "Helpdesk Team name..."
msgstr "Csapat neve..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,11 @@ msgstr "Cerca team Helpdesk"
msgid "Helpdesk Team name..."
msgstr "Nome team Helpdesk..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ msgstr ""
msgid "Helpdesk Team name..."
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ msgstr "Pesquisar na Equipa de Helpdesk"
msgid "Helpdesk Team name..."
msgstr "Nome da Equipe de helpdesk..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ msgstr "Buscar em Equipe de Atendimento"
msgid "Helpdesk Team name..."
msgstr "Buscar em Equipe de Atendimento"

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
5 changes: 5 additions & 0 deletions helpdesk_mgmt/i18n/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,11 @@ msgstr "Yardım Masası Ekibi Arama"
msgid "Helpdesk Team name..."
msgstr "Yardım Masası Ekip adı..."

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_stage__team_ids
msgid "Helpdesk Teams"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.actions.act_window,name:helpdesk_mgmt.action_helpdesk_ticket_kanban_from_dashboard
#: model:ir.model,name:helpdesk_mgmt.model_helpdesk_ticket
Expand Down
34 changes: 25 additions & 9 deletions helpdesk_mgmt/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,26 @@ class HelpdeskTicket(models.Model):
_mail_post_access = "read"
_inherit = ["mail.thread.cc", "mail.activity.mixin", "portal.mixin"]

def _get_default_stage_id(self):
return self.env["helpdesk.ticket.stage"].search([], limit=1).id
@api.depends("team_id")
def _compute_stage_id(self):
for ticket in self:
ticket.stage_id = ticket.team_id._get_applicable_stages()[:1]

@api.model
def _read_group_stage_ids(self, stages, domain, order):
stage_ids = self.env["helpdesk.ticket.stage"].search([])
return stage_ids
"""Show always the stages without team, or stages of the default team."""
search_domain = [
"|",
("id", "in", stages.ids),
("team_ids", "=", False),
]
default_team_id = self.default_get(["team_id"])["team_id"]
if default_team_id:
search_domain = [
"|",
("team_ids", "=", default_team_id),
] + search_domain
return stages.search(search_domain, order=order)

number = fields.Char(string="Ticket number", default="/", readonly=True)
name = fields.Char(string="Title", required=True)
Expand All @@ -34,17 +47,19 @@ def _read_group_stage_ids(self, stages, domain, order):
stage_id = fields.Many2one(
comodel_name="helpdesk.ticket.stage",
string="Stage",
group_expand="_read_group_stage_ids",
default=_get_default_stage_id,
tracking=True,
compute="_compute_stage_id",
store=True,
readonly=False,
ondelete="restrict",
index=True,
tracking=True,
group_expand="_read_group_stage_ids",
copy=False,
index=True,
domain="['|',('team_ids', '=', team_id),('team_ids','=',False)]",
)
partner_id = fields.Many2one(comodel_name="res.partner", string="Contact")
partner_name = fields.Char()
partner_email = fields.Char(string="Email")

last_stage_update = fields.Datetime(default=fields.Datetime.now)
assigned_date = fields.Datetime()
closed_date = fields.Datetime()
Expand All @@ -70,6 +85,7 @@ def _read_group_stage_ids(self, stages, domain, order):
team_id = fields.Many2one(
comodel_name="helpdesk.ticket.team",
string="Team",
index=True,
)
priority = fields.Selection(
selection=[
Expand Down
7 changes: 7 additions & 0 deletions helpdesk_mgmt/models/helpdesk_ticket_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class HelpdeskTicketStage(models.Model):
string="Company",
default=lambda self: self.env.company,
)
team_ids = fields.Many2many(
comodel_name="helpdesk.ticket.team",
relation="team_stage_rel",
string="Helpdesk Teams",
help="Specific team that uses this stage. If it is empty all teams could uses",
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
)

@api.onchange("closed")
def _onchange_closed(self):
Expand Down
16 changes: 15 additions & 1 deletion helpdesk_mgmt/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class HelpdeskTeam(models.Model):
inverse_name="team_id",
string="Tickets",
)

todo_ticket_count = fields.Integer(
string="Number of tickets", compute="_compute_todo_tickets"
)
Expand All @@ -67,6 +66,21 @@ class HelpdeskTeam(models.Model):
help="Allow to select this team when creating a new ticket in the portal.",
)

def _get_applicable_stages(self):
if self:
domain = [
("company_id", "in", [False, self.company_id.id]),
"|",
("team_ids", "=", False),
("team_ids", "=", self.id),
]
else:
domain = [
("company_id", "in", [False, self.env.company.id]),
("team_ids", "=", False),
]
return self.env["helpdesk.ticket.stage"].search(domain)

@api.depends("ticket_ids", "ticket_ids.stage_id")
def _compute_todo_tickets(self):
ticket_model = self.env["helpdesk.ticket"]
Expand Down
1 change: 1 addition & 0 deletions helpdesk_mgmt/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

* Pedro M. Baeza
* Víctor Martínez
* Carolina Fernandez

* `ID42 Sistemas <https://www.id42.com.br>`_:

Expand Down
3 changes: 2 additions & 1 deletion helpdesk_mgmt/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Helpdesk Management</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:37cc770b0537354407fedcbe0d568ba9bdd6aa460144a7af475c60ae3f91ad27
!! source digest: sha256:a417b3ef325ea73b03c6c64e0476702e5a35949224072491138ce827feb4d6e7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/helpdesk/tree/15.0/helpdesk_mgmt"><img alt="OCA/helpdesk" src="https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/helpdesk-15-0/helpdesk-15-0-helpdesk_mgmt"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds Helpdesk functionality in Odoo.</p>
Expand Down Expand Up @@ -568,6 +568,7 @@ <h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Pedro M. Baeza</li>
<li>Víctor Martínez</li>
<li>Carolina Fernandez</li>
</ul>
</li>
<li><a class="reference external" href="https://www.id42.com.br">ID42 Sistemas</a>:<ul>
Expand Down
1 change: 1 addition & 0 deletions helpdesk_mgmt/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def setUpClass(cls):
cls.team_b = helpdesk_ticket_team.create(
{"name": "Team B", "user_ids": [(6, 0, [cls.user_team.id])]}
)
cls.new_stage = cls.env.ref("helpdesk_mgmt.helpdesk_ticket_stage_new")
cls.ticket_a_unassigned = cls._create_ticket(cls, cls.team_a)
cls.ticket_a_unassigned.priority = "3"
cls.ticket_a_user_own = cls._create_ticket(cls, cls.team_a, cls.user_own)
Expand Down
34 changes: 34 additions & 0 deletions helpdesk_mgmt/tests/test_helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,37 @@ def test_helpdesk_ticket_message_new(self):
self.assertEqual(
t.name, title, "The ticket should have the correct (new) title."
)

def test_ticket_with_team_stage(self):
self.new_stage.team_ids = [(6, 0, [self.team_a.id, self.team_b.id])]
in_progress_stage = self.env.ref(
"helpdesk_mgmt.helpdesk_ticket_stage_in_progress"
)
in_progress_stage.team_ids = [(6, 0, [self.team_b.id])]
new_ticket = self.env["helpdesk.ticket"].create(
{
"name": "New Ticket",
"description": "Description",
"team_id": self.team_a.id,
"user_id": self.user.id,
"priority": "1",
}
)
self.assertEqual(new_ticket.stage_id, self.new_stage)
self.new_stage.team_ids = [(6, 0, [self.team_a.id])]
new_ticket.team_id = self.team_b
self.assertEqual(new_ticket.stage_id, in_progress_stage)
self.new_stage.team_ids = False
new_ticket.team_id = False
self.assertEqual(new_ticket.stage_id, self.new_stage)

def test_ticket_without_team(self):
new_ticket = self.env["helpdesk.ticket"].create(
{
"name": "New Ticket",
"description": "Description",
"user_id": self.user.id,
"priority": "1",
}
)
self.assertEqual(self.new_stage, new_ticket.stage_id)
Loading

0 comments on commit d45b96d

Please sign in to comment.