Skip to content

Commit

Permalink
feat: set customer reference based on domain field (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib authored Jul 27, 2023
1 parent 57f5634 commit 428d4ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions helpdesk/helpdesk/hooks/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ def get_list_filters(query):
)

return query

def before_insert(doc, method=None):
if doc.email_id:
domain = doc.email_id.split("@")[1]
hd_customers = frappe.get_all(
"HD Customer", filters={"domain": domain}, fields=["name"]
)
if hd_customers:
doc.append("links", {
"link_doctype": "HD Customer",
"link_name": hd_customers[0].name
})
1 change: 1 addition & 0 deletions helpdesk/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
],
},
"Contact": {
"before_insert": "helpdesk.helpdesk.hooks.contact.before_insert",
"on_trash": [
"helpdesk.helpdesk.doctype.hd_ticket.hd_ticket.update_ticket",
],
Expand Down

0 comments on commit 428d4ab

Please sign in to comment.