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

[16.0][IMP]helpdesk_mgmt: allow to define default team for a category #645

Open
wants to merge 1 commit into
base: 16.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
7 changes: 7 additions & 0 deletions helpdesk_mgmt/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def create(self, vals_list):
vals["number"] = self._prepare_ticket_number(vals)
if vals.get("user_id") and not vals.get("assigned_date"):
vals["assigned_date"] = fields.Datetime.now()
if not vals.get("team_id") and vals.get("category_id"):
vals["team_id"] = self._prepare_team_id(vals)
if vals.get("team_id"):
team = self.env["helpdesk.ticket.team"].browse([vals["team_id"]])
if team.company_id:
Expand Down Expand Up @@ -204,6 +206,11 @@ def _compute_access_url(self):
item.access_url = "/my/ticket/%s" % (item.id)
return res

def _prepare_team_id(self, values):
category = self.env["helpdesk.ticket.category"].browse(values["category_id"])
if category.default_team_id:
return category.default_team_id.id

# ---------------------------------------------------
# Mail gateway
# ---------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions helpdesk_mgmt/models/helpdesk_ticket_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ class HelpdeskCategory(models.Model):
string="Company",
default=lambda self: self.env.company,
)
default_team_id = fields.Many2one(
comodel_name="helpdesk.ticket.team",
string="Default team",
)
27 changes: 27 additions & 0 deletions helpdesk_mgmt/tests/test_helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,30 @@ def test_helpdesk_ticket_todo(self):
2,
"Helpdesk Ticket: Helpdesk ticket team should have two ticket to do.",
)

def test_helpdesk_ticket_team_from_category(self):
starting_ticket_amount = self.team_a.todo_ticket_count
category = self.env.ref("helpdesk_mgmt.helpdesk_category_1")
self.env["helpdesk.ticket"].create(
{
"name": "Ticket 1",
"description": "Description",
"category_id": category.id,
}
)
self.assertEqual(
self.team_a.todo_ticket_count,
starting_ticket_amount,
)
category.default_team_id = self.team_a
self.env["helpdesk.ticket"].create(
{
"name": "Ticket 1",
"description": "Description",
"category_id": category.id,
}
)
self.assertEqual(
self.team_a.todo_ticket_count,
starting_ticket_amount + 1,
)
1 change: 1 addition & 0 deletions helpdesk_mgmt/views/helpdesk_ticket_category_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
</h1>
</div>
<group name="main">
<field name="default_team_id" />
<field name="company_id" groups="base.group_multi_company" />
<field name="active" invisible="1" />
</group>
Expand Down
Loading