Skip to content

Commit

Permalink
[IMP] helpdesk_ticket_type_team
Browse files Browse the repository at this point in the history
  • Loading branch information
SMaciasOSI committed Jan 29, 2024
1 parent 4b22d6a commit 9787317
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 38 deletions.
47 changes: 22 additions & 25 deletions helpdesk_ticket_type_team/README.rst
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
**This file is going to be generated by oca-gen-addon-readme.**
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

*Manual changes will be overwritten.*
========
Overview
========

Please provide content in the ``readme`` directory:
This module restricts the visibility of helpdesk ticket types based on the teams assigned to them.

* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)
Every ticket type can only have a single team assigned to it.

Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.
Configuration
=============

A good, one sentence summary in the manifest is also highly recommended.
* Go to Helpdesk/Configuration/Types to assign a team to the ticket types
* Alternatively, you can go Helpdesk/Configuration/Teams, and inside the form view you can assign the ticket types to the team

Usage
=====

Automatic changelog generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Assign ticket types to teams
* When creating a new ticket, only the assigned ticket types will be visible when selecting the team

`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_.
Credits
=======

Just put towncrier compatible changelog fragments into `readme/newsfragments`
and the changelog file will be automatically generated and updated when a new fragment is added.
Contributors
------------

Please refer to `towncrier` documentation to know more.

NOTE: the changelog will be automatically generated when using `/ocabot merge $option`.
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_.
Samuel Macias <smacias@opensourceintegrators.com>
Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
15 changes: 2 additions & 13 deletions helpdesk_ticket_type_team/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,9 @@ class HelpdeskTicket(models.Model):
_inherit = "helpdesk.ticket"

@api.onchange("team_id")
def _onchange_ticket_type_id(self):
def _onchange_team_id(self):
self.ticket_type_id = False
if not self.team_id or not self.team_id.ticket_type_ids:
return {"domain": {"ticket_type_id": [("team_id", "=", False)]}}
else:
ticket_types = self.env["helpdesk.ticket.type"].search(
[("team_id", "=", self.team_id.id)]
)
if len(ticket_types) == 1:
self.ticket_type_id = ticket_types[0].id
return {
"domain": {"ticket_type_id": [("team_id", "=", self.team_id.id)]}
}
elif len(ticket_types) > 1:
return {
"domain": {"ticket_type_id": [("team_id", "=", self.team_id.id)]}
}
return {"domain": {"ticket_type_id": [("team_id", "=", self.team_id.id)]}}

0 comments on commit 9787317

Please sign in to comment.