Merge pull request #7205 from nabinhait/hotfix

Address naming if multiple address for same type
This commit is contained in:
Nabin Hait 2016-12-14 12:50:01 +05:30 committed by GitHub
commit 4b5ab6a0d0

View File

@ -10,6 +10,7 @@ from frappe.utils import cstr
from frappe.model.document import Document from frappe.model.document import Document
from jinja2 import TemplateSyntaxError from jinja2 import TemplateSyntaxError
from frappe.utils.user import is_website_user from frappe.utils.user import is_website_user
from frappe.model.naming import make_autoname
class Address(Document): class Address(Document):
def __setup__(self): def __setup__(self):
@ -21,7 +22,10 @@ class Address(Document):
or self.supplier or self.sales_partner or self.lead or self.supplier or self.sales_partner or self.lead
if self.address_title: 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: else:
throw(_("Address Title is mandatory.")) throw(_("Address Title is mandatory."))