Skip to content

Commit

Permalink
Merge PR OCA#589 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jul 1, 2024
2 parents a5bfe07 + 4a2fa74 commit 8a5cb7c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
13 changes: 11 additions & 2 deletions helpdesk_mgmt/demo/helpdesk_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
<field eval="&quot;General Alias for tickets&quot;" name="alias_name" />
<field ref="model_helpdesk_ticket" name="alias_model_id" />
</record>
<record id="mail_alias_2" model="mail.alias">
<field eval="&quot;General Alias 2 for tickets&quot;" name="alias_name" />
<field ref="model_helpdesk_ticket" name="alias_model_id" />
</record>
<record id="mail_alias_3" model="mail.alias">
<field eval="&quot;General Alias 3 for tickets&quot;" name="alias_name" />
<field ref="model_helpdesk_ticket" name="alias_model_id" />
</record>

<!-- Teams -->
<record id="helpdesk_team_1" model="helpdesk.ticket.team">
<field eval="&quot;Localization team&quot;" name="name" />
Expand All @@ -46,15 +55,15 @@
<field eval="&quot;1&quot;" name="active" />
<field name="category_ids" eval="[(6,0,[ref('helpdesk_category_1')])]" />
<field name="company_id" ref="base.main_company" />
<field name="alias_id" ref="mail_alias_1" />
<field name="alias_id" ref="mail_alias_2" />
</record>
<record id="helpdesk_team_3" model="helpdesk.ticket.team">
<field eval="&quot;Consultants&quot;" name="name" />
<field name="user_ids" eval="[(6,0,[ref('base.user_root')])]" />
<field eval="&quot;1&quot;" name="active" />
<field name="category_ids" eval="[(6,0,[ref('helpdesk_category_2')])]" />
<field name="company_id" ref="base.main_company" />
<field name="alias_id" ref="mail_alias_1" />
<field name="alias_id" ref="mail_alias_3" />
</record>
<!-- Tags -->
<record id="helpdesk_tag_1" model="helpdesk.ticket.tag">
Expand Down
9 changes: 9 additions & 0 deletions helpdesk_mgmt/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def _compute_stage_id(self):
for ticket in self:
ticket.stage_id = ticket.team_id._get_applicable_stages()[:1]

@api.depends("team_id")
def _compute_user_id(self):
for ticket in self:
if not ticket.user_id and ticket.team_id:
ticket.user_id = ticket.team_id.alias_user_id

@api.model
def _read_group_stage_ids(self, stages, domain, order):
"""Show always the stages without team, or stages of the default team."""
Expand All @@ -40,6 +46,9 @@ def _read_group_stage_ids(self, stages, domain, order):
string="Assigned user",
tracking=True,
index=True,
compute="_compute_user_id",
store=True,
readonly=False,
domain="team_id and [('share', '=', False),('id', 'in', user_ids)] or [('share', '=', False)]", # noqa: B950
)
user_ids = fields.Many2many(
Expand Down
7 changes: 6 additions & 1 deletion helpdesk_mgmt/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setUpClass(cls):
cls.ticket_b_user_team = cls._create_ticket(cls, cls.team_b, cls.user_team)

def _create_ticket(self, team, user=False):
return self.env["helpdesk.ticket"].create(
ticket = self.env["helpdesk.ticket"].create(
{
"name": "Ticket %s (%s)"
% (team.name, user.login if user else "unassigned"),
Expand All @@ -59,3 +59,8 @@ def _create_ticket(self, team, user=False):
"priority": "1",
}
)
# Since compute/depends method is added on user_id field
# it's now necessary to write unassigned user for the tests
if not user:
ticket.user_id = False
return ticket

0 comments on commit 8a5cb7c

Please sign in to comment.