Merge pull request #48151 from khushi8112/duplicate-naming-issue-in-contract-doctype

fix: duplicate naming issue in contract doctype
This commit is contained in:
Khushi Rawat
2025-06-20 12:58:10 +05:30
committed by GitHub
2 changed files with 5 additions and 14 deletions

View File

@@ -2,6 +2,7 @@
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "CON-.YYYY.-.#####",
"creation": "2018-04-12 06:32:04.582486",
"doctype": "DocType",
"editable_grid": 1,
@@ -256,10 +257,11 @@
"grid_page_length": 50,
"is_submittable": 1,
"links": [],
"modified": "2025-05-23 13:54:03.346537",
"modified": "2025-06-19 17:48:45.049007",
"modified_by": "Administrator",
"module": "CRM",
"name": "Contract",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
@@ -324,10 +326,12 @@
}
],
"row_format": "Dynamic",
"search_fields": "party_type, party_name, contract_template",
"show_name_in_global_search": 1,
"sort_field": "creation",
"sort_order": "DESC",
"states": [],
"title_field": "party_name",
"track_changes": 1,
"track_seen": 1
}

View File

@@ -46,19 +46,6 @@ class Contract(Document):
status: DF.Literal["Unsigned", "Active", "Inactive"]
# end: auto-generated types
def autoname(self):
name = self.party_name
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)
def validate(self):
self.set_missing_values()
self.validate_dates()