Merge pull request #48175 from frappe/mergify/bp/version-15-hotfix/pr-48151

fix: duplicate naming issue in contract doctype (backport #48151)
This commit is contained in:
Khushi Rawat
2025-06-22 00:47:47 +05:30
committed by GitHub
2 changed files with 6 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,9 +326,12 @@
}
],
"row_format": "Dynamic",
"search_fields": "party_type, party_name, contract_template",
"show_name_in_global_search": 1,
"sort_field": "modified",
"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()