Skip to content

Commit

Permalink
[FIX] helpdesk_mgmt_activity: Assigned user is added for ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
geomer198 committed Oct 23, 2024
1 parent d949b2f commit d595725
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 6 additions & 1 deletion helpdesk_mgmt_activity/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class HelpdeskTicket(models.Model):
store=True,
index=True,
)
assigned_user_id = fields.Many2one(
comodel_name="res.users",
)
is_new_stage = fields.Boolean(compute="_compute_is_new_stage")

@api.model
Expand Down Expand Up @@ -122,6 +125,8 @@ def _check_activity_values(self):
raise models.UserError(_("Activity Type is not set!"))
if not self.date_deadline:
raise models.UserError(_("Date Deadline is not set!"))
if not self.assigned_user_id:
raise models.UserError(_("Assigned User is not set!"))

def perform_action(self):
"""Perform action for ticket"""
Expand All @@ -136,7 +141,7 @@ def perform_action(self):
date_deadline=self.date_deadline,
activity_type_id=self.source_activity_type_id.id,
ticket_id=self.id,
user_id=self.user_id.id,
user_id=self.assigned_user_id.id,
)
self.set_next_stage()
except Exception as e:
Expand Down
14 changes: 13 additions & 1 deletion helpdesk_mgmt_activity/tests/test_helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def create_ticket_and_activity(self):
"record_ref": f"res.partner,{self.test_partner.id}",
"source_activity_type_id": self.activity_type_meeting.id,
"date_deadline": Date.today(),
"assigned_user_id": self.env.user.id,
}
)
ticket.perform_action()
Expand Down Expand Up @@ -62,6 +63,7 @@ def test_ticket_next_stage(self):
"record_ref": f"res.partner,{self.test_partner.id}",
"source_activity_type_id": self.activity_type_meeting.id,
"date_deadline": Date.today(),
"assigned_user_id": self.env.user.id,
}
)

Expand Down Expand Up @@ -168,6 +170,16 @@ def test_perform_action(self):

ticket.date_deadline = Date.today()

with self.assertRaises(UserError) as error:
ticket.perform_action()
self.assertEqual(
error.exception.args[0],
"Assigned User is not set!",
"Errors must be the same",
)

ticket.assigned_user_id = self.env.user

action = ticket.perform_action()

self.assertDictEqual(
Expand All @@ -193,7 +205,7 @@ def test_perform_action(self):
"date_deadline": ticket.date_deadline,
"activity_type_id": ticket.source_activity_type_id.id,
"ticket_id": ticket.id,
"user_id": ticket.user_id.id,
"user_id": self.env.user.id,
}
],
)
Expand Down
4 changes: 4 additions & 0 deletions helpdesk_mgmt_activity/views/helpdesk_ticket_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
name="date_deadline"
attrs="{'invisible': [('source_activity_type_id', '=', False)]}"
/>
<field
name="assigned_user_id"
attrs="{'invisible': [('source_activity_type_id', '=', False)]}"
/>
</group>
</group>
</field>
Expand Down

0 comments on commit d595725

Please sign in to comment.