mirror of
https://github.com/hanzoai/helpdesk.git
synced 2026-10-12 16:56:02 +00:00
fix: auto set customer setting
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_bulk_edit": 1,
|
||||
"creation": "2017-02-17 13:07:35.686409",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
@@ -39,6 +40,8 @@
|
||||
"enable_outside_hours_banner",
|
||||
"outside_working_hours_message",
|
||||
"column_break_fzef",
|
||||
"ticket_routing_section",
|
||||
"auto_set_customer_from_contact",
|
||||
"status_section",
|
||||
"default_ticket_status",
|
||||
"column_break_yfbu",
|
||||
@@ -504,12 +507,24 @@
|
||||
"fieldname": "enable_outside_hours_banner",
|
||||
"fieldtype": "Check",
|
||||
"label": "Apply outside working hours"
|
||||
},
|
||||
{
|
||||
"fieldname": "ticket_routing_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Ticket Routing"
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"description": "Automatically set the customer on a ticket based on the contact's linked customer(s)",
|
||||
"fieldname": "auto_set_customer_from_contact",
|
||||
"fieldtype": "Check",
|
||||
"label": "Auto-set customer from contact"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2026-01-23 18:30:40.906948",
|
||||
"modified": "2026-06-29 18:07:35.389430",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Helpdesk",
|
||||
"name": "HD Settings",
|
||||
|
||||
@@ -267,6 +267,11 @@ class HDTicket(Document):
|
||||
self.contact = contact
|
||||
|
||||
def set_customer(self):
|
||||
if not frappe.db.get_single_value(
|
||||
"HD Settings", "auto_set_customer_from_contact"
|
||||
):
|
||||
return
|
||||
|
||||
# For existing tickets, only validate if customer value has changed
|
||||
if not self.is_new() and not self.has_value_changed("customer"):
|
||||
return
|
||||
|
||||
@@ -23,8 +23,11 @@ def get_one(name: str):
|
||||
fields = get_fields_meta(name)
|
||||
customers = get_customers()
|
||||
|
||||
auto_set_customer_from_contact = frappe.db.get_single_value(
|
||||
"HD Settings", "auto_set_customer_from_contact"
|
||||
)
|
||||
has_customer_field = any(f.fieldname == "customer" for f in fields)
|
||||
if len(customers) > 1 and not has_customer_field:
|
||||
if auto_set_customer_from_contact and len(customers) > 1 and not has_customer_field:
|
||||
fields.append(
|
||||
frappe._dict(
|
||||
fieldname="customer",
|
||||
|
||||
@@ -45,3 +45,4 @@ helpdesk.patches.add_customer_and_customer_manager_role
|
||||
helpdesk.patches.move_contact_dynamic_link_to_hd_customer
|
||||
helpdesk.patches.set_default_customer_type
|
||||
helpdesk.patches.add_user_invitation_perms
|
||||
helpdesk.patches.enable_auto_set_customer_from_contact
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.set_single_value(
|
||||
"HD Settings",
|
||||
"auto_set_customer_from_contact",
|
||||
1,
|
||||
)
|
||||
Reference in New Issue
Block a user