From e13e2bffe264180c2effc3c2cf36c4f0b15c384f Mon Sep 17 00:00:00 2001 From: khushi Date: Thu, 19 Jun 2025 14:03:42 +0530 Subject: [PATCH] fix: contract autoname --- erpnext/crm/doctype/contract/contract.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/erpnext/crm/doctype/contract/contract.py b/erpnext/crm/doctype/contract/contract.py index 64f89552062..559c89a9629 100644 --- a/erpnext/crm/doctype/contract/contract.py +++ b/erpnext/crm/doctype/contract/contract.py @@ -6,6 +6,7 @@ import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import getdate, nowdate +from frappe.model.naming import append_number_if_name_exists class Contract(Document): @@ -52,12 +53,7 @@ class Contract(Document): if self.contract_template: name += f" - {self.contract_template} Agreement" - # If identical, append contract name with the next number in the iteration - if frappe.db.exists("Contract", name): - count = len(frappe.get_all("Contract", filters={"name": ["like", f"%{name}%"]})) - name = f"{name} - {count}" - - self.name = _(name) + self.name = append_number_if_name_exists("Contract", name) def validate(self): self.set_missing_values()