mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
[autoname] [cleanup] strip blank spaces and remove autoname where naming_series: can be set in doctype
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user