[fix] [minor] supplier & customer rename fix

This commit is contained in:
Akhilesh Darjee 2013-12-10 14:22:52 +05:30
parent 5d3da6c095
commit abefa3fd40
2 changed files with 40 additions and 20 deletions

View File

@ -27,6 +27,14 @@ class DocType(TransactionBase):
else:
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
def update_address(self):
webnotes.conn.sql("""update `tabAddress` set supplier_name=%s
where supplier=%s""", (self.doc.supplier_name, self.doc.name))
def update_contact(self):
webnotes.conn.sql("""update `tabContact` set supplier_name=%s
where supplier=%s""", (self.doc.supplier_name, self.doc.name))
def update_credit_days_limit(self):
webnotes.conn.sql("""update tabAccount set credit_days = %s where name = %s""",
(cint(self.doc.credit_days), self.doc.name + " - " + self.get_company_abbr()))
@ -35,6 +43,9 @@ class DocType(TransactionBase):
if not self.doc.naming_series:
self.doc.naming_series = ''
self.update_address()
self.update_contact()
# create account head
self.create_account_head()
@ -151,20 +162,19 @@ class DocType(TransactionBase):
def before_rename(self, olddn, newdn, merge=False):
from accounts.utils import rename_account_for
rename_account_for("Supplier", olddn, newdn, merge)
self.rename_address(olddn, newdn)
self.rename_contact(olddn, newdn)
def rename_address(self, olddn, newdn):
webnotes.conn.sql("""update `tabAddress` set supplier_name=%s,
address_title=%s where supplier=%s""", (newdn, newdn, olddn))
def rename_contact(self,olddn, newdn):
webnotes.conn.sql("""update `tabContact` set supplier_name=%s
where supplier=%s""", (newdn, olddn))
def after_rename(self, olddn, newdn, merge=False):
condition = value = ''
if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name':
webnotes.conn.set(self.doc, "supplier_name", newdn)
self.update_contact()
condition = ", supplier_name=%s"
value = newdn
self.update_supplier_address(newdn, condition, value)
def update_supplier_address(self, newdn, condition, value):
webnotes.conn.sql("""update `tabAddress` set address_title=%s %s
where supplier=%s""" % ('%s', condition, '%s'), (newdn, value, newdn))
@webnotes.whitelist()
def get_dashboard_info(supplier):

View File

@ -47,6 +47,14 @@ class DocType(TransactionBase):
if self.doc.lead_name:
webnotes.conn.sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name)
def update_address(self):
webnotes.conn.sql("""update `tabAddress` set customer_name=%s where customer=%s""",
(self.doc.customer_name, self.doc.name))
def update_contact(self):
webnotes.conn.sql("""update `tabContact` set customer_name=%s where customer=%s""",
(self.doc.customer_name, self.doc.name))
def create_account_head(self):
if self.doc.company :
abbr = self.get_company_abbr()
@ -99,6 +107,9 @@ class DocType(TransactionBase):
self.validate_name_with_customer_group()
self.update_lead_status()
self.update_address()
self.update_contact()
# create account head
self.create_account_head()
# update credit days and limit in account
@ -146,20 +157,19 @@ class DocType(TransactionBase):
def before_rename(self, olddn, newdn, merge=False):
from accounts.utils import rename_account_for
rename_account_for("Customer", olddn, newdn, merge)
self.rename_address(olddn, newdn)
self.rename_contact(olddn, newdn)
def rename_address(self, olddn, newdn):
webnotes.conn.sql("""update `tabAddress` set customer_name=%s,
address_title=%s where customer=%s""", (newdn, newdn, olddn))
def rename_contact(self,olddn, newdn):
webnotes.conn.sql("""update `tabContact` set customer_name=%s
where customer=%s""", (newdn, olddn))
def after_rename(self, olddn, newdn, merge=False):
condition = value = ''
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
webnotes.conn.set(self.doc, "customer_name", newdn)
self.update_contact()
condition = ", customer_name=%s"
value = newdn
self.update_customer_address(newdn, condition, value)
def update_customer_address(self, newdn, condition, value):
webnotes.conn.sql("""update `tabAddress` set address_title=%s %s
where customer=%s""" % ('%s', condition, '%s'), (newdn, value, newdn))
@webnotes.whitelist()
def get_dashboard_info(customer):