Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta
2013-01-24 15:56:15 +05:30
6 changed files with 52 additions and 18 deletions

View File

@@ -172,6 +172,8 @@ class DocType(TransactionBase):
pass
def on_update(self):
self.validate_name_with_customer_group()
self.update_lead_status()
# create account head
self.create_account_head()
@@ -179,6 +181,12 @@ class DocType(TransactionBase):
self.update_credit_days_limit()
#create address and contact from lead
self.create_lead_address_contact()
def validate_name_with_customer_group(self):
if webnotes.conn.exists("Customer Group", self.doc.name):
webnotes.msgprint("An Customer Group exists with same name (%s), \
please change the Customer name or rename the Customer Group" %
self.doc.name, raise_exception=1)
def delete_customer_address(self):
for rec in sql("select * from `tabAddress` where customer='%s'" %(self.doc.name), as_dict=1):

View File

@@ -18,12 +18,16 @@ def get_children():
@webnotes.whitelist()
def add_node():
from webnotes.model.doc import Document
# from webnotes.model.doc import Document
ctype = webnotes.form_dict.get('ctype')
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
d = Document(ctype)
d.fields[ctype.lower().replace(' ', '_') + '_name'] = webnotes.form_dict['name_field']
d.fields[parent_field] = webnotes.form_dict['parent']
d.is_group = webnotes.form_dict['is_group']
d.save()
name_field = ctype.lower().replace(' ', '_') + '_name'
doclist = [{
"doctype": ctype,
"__islocal": 1,
name_field: webnotes.form_dict['name_field'],
parent_field: webnotes.form_dict['parent'],
"is_group": webnotes.form_dict['is_group']
}]
webnotes.model_wrapper(doclist).save()