-
Notifications
You must be signed in to change notification settings - Fork 713
feat: enhance agent profile with availability status and signature #3002
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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
6d4192f
e52454d
910edf4
3171e12
54ce1dd
6b4bc87
e1d108a
29732e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| // Copyright (c) 2022, Frappe Technologies and contributors | ||
| // For license information, please see license.txt | ||
|
|
||
| frappe.ui.form.on("HD Agent", { | ||
| // refresh: function(frm) { | ||
| // } | ||
| frappe.ui.form.on('HD Agent', { | ||
| refresh: function(frm) { | ||
| // Example: make status editable | ||
| frm.set_df_property('availability_status', 'read_only', 0); | ||
| } | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,9 @@ | |
| "user", | ||
| "agent_name", | ||
| "user_image", | ||
| "is_active" | ||
| "is_active", | ||
| "availability_status", | ||
| "signature" | ||
| ], | ||
| "fields": [ | ||
| { | ||
|
|
@@ -34,6 +36,21 @@ | |
| "in_list_view": 1, | ||
| "label": "Is Active" | ||
| }, | ||
| { | ||
| "default": "Available", | ||
| "fieldname": "availability_status", | ||
| "fieldtype": "Select", | ||
| "in_list_view": 1, | ||
| "label": "Availability Status", | ||
| "options": "Available\nAway", | ||
| "reqd": 1 | ||
| }, | ||
| { | ||
| "description": "automatically added in reply section", | ||
| "fieldname": "signature", | ||
| "fieldtype": "Small Text", | ||
| "label": "Signature" | ||
|
Comment on lines
12
to
+52
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that these are also shown in the "Profile" tab shown in "Settings Modal" both signature and status field
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Fixed in commit 910edf4 — added both fields to Profile.vue" |
||
| }, | ||
| { | ||
| "fieldname": "user_image", | ||
| "fieldtype": "Attach Image", | ||
|
|
@@ -42,7 +59,7 @@ | |
| ], | ||
| "index_web_pages_for_search": 1, | ||
| "links": [], | ||
| "modified": "2026-02-02 11:15:47.402850", | ||
| "modified": "2026-02-09 22:08:22.055831", | ||
| "modified_by": "Administrator", | ||
| "module": "Helpdesk", | ||
| "name": "HD Agent", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -424,7 +424,12 @@ def users_present_in_team_assignment_rule(self): | |
| return True | ||
|
|
||
| @frappe.whitelist() | ||
| def assign_agent(self, agent: str): | ||
| def assign_agent(self, agent): | ||
| availability = frappe.db.get_value("HD Agent", agent, "availability_status") | ||
|
|
||
| if availability == "Away": | ||
| frappe.throw("This agent is marked as Away and cannot be assigned tickets.") | ||
|
|
||
|
||
| assign({"assign_to": [agent], "doctype": "HD Ticket", "name": self.name}) | ||
|
|
||
| if frappe.session.user != agent: | ||
|
|
@@ -558,6 +563,11 @@ def reply_via_agent( | |
| medium = "" if skip_email_workflow else "Email" | ||
| subject = f"Re: {self.subject}" | ||
| sender = frappe.session.user | ||
| # Append agent signature if present | ||
| signature = frappe.db.get_value("HD Agent", {"user": sender}, "signature") | ||
| if signature and signature not in message: | ||
| message = f"{message}\n\n{signature}" | ||
|
||
|
|
||
| recipients = to or self.raised_by | ||
| sender_email = None if skip_email_workflow else self.sender_email() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import frappe | ||
| from frappe import _ | ||
|
|
||
|
|
||
| def validate_agent_availability(doc, method=None): | ||
| if not doc.allocated_to: | ||
| return | ||
|
|
||
| status = frappe.db.get_value( | ||
| "HD Agent", | ||
| {"user": doc.allocated_to}, | ||
| "availability_status", | ||
| ) | ||
|
|
||
| if status == "Away": | ||
| frappe.throw( | ||
| msg=_("This agent is marked as Away and cannot be assigned tickets."), | ||
| title=_("Agent Unavailable"), | ||
| exc=frappe.ValidationError, | ||
| ) | ||
|
Comment on lines
+21
to
+26
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not throw error, we could do frappe.msgprint and frappe.log_error instead coz let us say if a ticket was about to be created and then it got assigned to an agent who is unavailable, then the system will throw an error and the ticket will not be created. We should not block ticket creation process.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Fixed in commit 910edf4 — replaced with frappe.msgprint and frappe.log_error" |
||
|
|
||
| def user_query_condition(user): | ||
| return """ | ||
| EXISTS ( | ||
| SELECT 1 FROM `tabHD Agent` | ||
| WHERE `tabHD Agent`.user = `tabUser`.name | ||
| AND `tabHD Agent`.availability_status = 'Available' | ||
| ) | ||
| """ | ||
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the unwanted code