Merge pull request #3503 from RitvikSardana/fix/customer-ticket
fix: set customer only for new tickets
This commit is contained in:
@@ -267,6 +267,10 @@ class HDTicket(Document):
|
||||
self.contact = contact
|
||||
|
||||
def set_customer(self):
|
||||
# For existing tickets, only validate if customer value has changed
|
||||
if not self.is_new() and not self.has_value_changed("customer"):
|
||||
return
|
||||
|
||||
contact_customers = get_customers(contact=self.contact) if self.contact else []
|
||||
|
||||
if self.customer:
|
||||
@@ -278,9 +282,10 @@ class HDTicket(Document):
|
||||
).format(self.customer, self.contact),
|
||||
frappe.ValidationError,
|
||||
)
|
||||
return # customer is set and valid, return early
|
||||
return
|
||||
|
||||
if self.contact:
|
||||
# Auto-set customer only for new tickets
|
||||
if self.is_new() and self.contact:
|
||||
if len(contact_customers) == 1:
|
||||
self.customer = contact_customers[0]
|
||||
elif (
|
||||
|
||||
Reference in New Issue
Block a user