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

[15.0] [FIX] helpdesk_mgmt: company_id should come from team #553

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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
16 changes: 12 additions & 4 deletions helpdesk_mgmt/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ def _read_group_stage_ids(self, stages, domain, order):
] + search_domain
return stages.search(search_domain, order=order)

def _default_team_id(self):
team_id = (
self.env["helpdesk.ticket.team"]
.search([("user_ids", "in", self.env.uid)], limit=1)
.id
)
if not team_id:
team_id = self.env["helpdesk.ticket.team"].search([], limit=1).id
return team_id

number = fields.Char(string="Ticket number", default="/", readonly=True)
name = fields.Char(string="Title", required=True)
description = fields.Html(required=True, sanitize_style=True)
Expand Down Expand Up @@ -67,10 +77,7 @@ def _read_group_stage_ids(self, stages, domain, order):
unattended = fields.Boolean(related="stage_id.unattended", store=True)
tag_ids = fields.Many2many(comodel_name="helpdesk.ticket.tag", string="Tags")
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
required=True,
default=lambda self: self.env.company,
related="team_id.company_id", string="Company", store=True, readonly=True
)
channel_id = fields.Many2one(
comodel_name="helpdesk.ticket.channel",
Expand All @@ -86,6 +93,7 @@ def _read_group_stage_ids(self, stages, domain, order):
comodel_name="helpdesk.ticket.team",
string="Team",
index=True,
default=_default_team_id,
)
priority = fields.Selection(
selection=[
Expand Down
Loading