[autoname] [cleanup] strip blank spaces and remove autoname where naming_series: can be set in doctype

This commit is contained in:
Anand Doshi
2013-05-09 15:13:47 +05:30
parent 21b854b7cc
commit ef06a4b349
13 changed files with 28 additions and 71 deletions

View File

@@ -18,6 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes import msgprint
from webnotes.utils import cstr
class DocType:
def __init__(self, doc, doclist=[]):
@@ -29,7 +30,7 @@ class DocType:
self.doc.address_title = self.doc.customer or self.doc.supplier or self.doc.sales_partner
if self.doc.address_title:
self.doc.name = self.doc.address_title + "-" + self.doc.address_type
self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip()
else:
webnotes.msgprint("""Address Title is mandatory.""", raise_exception=True)

View File

@@ -16,7 +16,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr
from utilities.transaction_base import TransactionBase
@@ -32,15 +32,16 @@ class DocType(TransactionBase):
webnotes.conn.set(self.doc, 'status', 'Replied')
def autoname(self):
if self.doc.customer:
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer
elif self.doc.supplier:
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier
elif self.doc.sales_partner:
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner
else:
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '')
# concat first and last name
self.doc.name = " ".join(filter(None,
[cstr(self.doc.fields.get(f)).strip() for f in ["first_name", "last_name"]]))
# concat party name if reqd
for fieldname in ("customer", "supplier", "sales_partner"):
if self.doc.fields.get(fieldname):
self.doc.name = self.doc.name + "-" + cstr(self.doc.fields.get(fieldname)).strip()
break
def validate(self):
self.validate_primary_contact()