Address naming if multiple address for same type

This commit is contained in:
Nabin Hait 2016-12-13 14:50:20 +05:30
parent 3bfe01d1e0
commit 80cea9795e

View File

@ -10,6 +10,7 @@ from frappe.utils import cstr
from frappe.model.document import Document
from jinja2 import TemplateSyntaxError
from frappe.utils.user import is_website_user
from frappe.model.naming import make_autoname
class Address(Document):
def __setup__(self):
@ -21,7 +22,10 @@ class Address(Document):
or self.supplier or self.sales_partner or self.lead
if self.address_title:
self.name = cstr(self.address_title).strip() + "-" + cstr(self.address_type).strip()
self.name = (cstr(self.address_title).strip() + "-" + cstr(self.address_type).strip())
if frappe.db.exists("Address", self.name):
self.name = make_autoname(cstr(self.address_title).strip() + "-" +
cstr(self.address_type).strip() + "-.#")
else:
throw(_("Address Title is mandatory."))