From 4c8558665d7f0d167d880880b16c1facb4bfa2ce Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 3 Feb 2015 10:35:32 +0530 Subject: [PATCH] [todo] naming as hash --- frappe/desk/doctype/todo/todo.json | 4 ++-- frappe/model/base_document.py | 3 +++ frappe/model/naming.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frappe/desk/doctype/todo/todo.json b/frappe/desk/doctype/todo/todo.json index 2c6e0faf2d..26f9640a89 100644 --- a/frappe/desk/doctype/todo/todo.json +++ b/frappe/desk/doctype/todo/todo.json @@ -1,7 +1,7 @@ { "allow_copy": 0, "allow_rename": 0, - "autoname": "TDI.########", + "autoname": "hash", "creation": "2012-07-03 13:30:35", "docstatus": 0, "doctype": "DocType", @@ -170,7 +170,7 @@ "in_dialog": 0, "issingle": 0, "max_attachments": 0, - "modified": "2015-01-22 17:54:50.026008", + "modified": "2015-02-02 06:38:35.187657", "modified_by": "Administrator", "module": "Desk", "name": "ToDo", diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index 8c3069c246..e1097a647c 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -197,6 +197,9 @@ class BaseDocument(object): ), d.values()) except Exception, e: if e.args[0]==1062: + if self.meta.autoname=="hash": + self.db_insert() + return type, value, traceback = sys.exc_info() frappe.msgprint(_("Duplicate name {0} {1}").format(self.doctype, self.name)) raise frappe.NameError, (self.doctype, self.name, e), traceback diff --git a/frappe/model/naming.py b/frappe/model/naming.py index 40fd48503d..be44e729cf 100644 --- a/frappe/model/naming.py +++ b/frappe/model/naming.py @@ -76,7 +76,7 @@ def make_autoname(key, doctype=''): DE/09/01/0001 where 09 is the year, 01 is the month and 0001 is the series """ if key=="hash": - return frappe.generate_hash(doctype) + return frappe.generate_hash(doctype)[:7] if not "#" in key: key = key + ".#####"