[fix] [minor] allowed renaming for address and contact

This commit is contained in:
Akhilesh Darjee 2013-12-12 12:32:43 +05:30
parent 229b246d6d
commit 7d4c2d62bf
4 changed files with 24 additions and 22 deletions

View File

@ -28,11 +28,11 @@ class DocType(TransactionBase):
self.doc.name = make_autoname(self.doc.naming_series + '.#####') self.doc.name = make_autoname(self.doc.naming_series + '.#####')
def update_address(self): def update_address(self):
webnotes.conn.sql("""update `tabAddress` set supplier_name=%s webnotes.conn.sql("""update `tabAddress` set supplier_name=%s, modified=NOW()
where supplier=%s""", (self.doc.supplier_name, self.doc.name)) where supplier=%s""", (self.doc.supplier_name, self.doc.name))
def update_contact(self): def update_contact(self):
webnotes.conn.sql("""update `tabContact` set supplier_name=%s webnotes.conn.sql("""update `tabContact` set supplier_name=%s, modified=NOW()
where supplier=%s""", (self.doc.supplier_name, self.doc.name)) where supplier=%s""", (self.doc.supplier_name, self.doc.name))
def update_credit_days_limit(self): def update_credit_days_limit(self):
@ -164,17 +164,17 @@ class DocType(TransactionBase):
rename_account_for("Supplier", olddn, newdn, merge) rename_account_for("Supplier", olddn, newdn, merge)
def after_rename(self, olddn, newdn, merge=False): def after_rename(self, olddn, newdn, merge=False):
condition = value = '' set_field = ''
if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name': if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name':
webnotes.conn.set(self.doc, "supplier_name", newdn) webnotes.conn.set(self.doc, "supplier_name", newdn)
self.update_contact() self.update_contact()
condition = ", supplier_name=%s" set_field = ", supplier_name=%(newdn)s"
value = newdn self.update_supplier_address(newdn, set_field)
self.update_supplier_address(newdn, condition, value)
def update_supplier_address(self, newdn, condition, value): def update_supplier_address(self, newdn, set_field):
webnotes.conn.sql("""update `tabAddress` set address_title=%s %s webnotes.conn.sql("""update `tabAddress` set address_title=%(newdn)s
where supplier=%s""" % ('%s', condition, '%s'), (newdn, value, newdn)) {set_field} where supplier=%(newdn)s"""\
.format(set_field=set_field), ({"newdn": newdn}))
@webnotes.whitelist() @webnotes.whitelist()
def get_dashboard_info(supplier): def get_dashboard_info(supplier):

View File

@ -48,12 +48,12 @@ class DocType(TransactionBase):
webnotes.conn.sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name) webnotes.conn.sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name)
def update_address(self): def update_address(self):
webnotes.conn.sql("""update `tabAddress` set customer_name=%s where customer=%s""", webnotes.conn.sql("""update `tabAddress` set customer_name=%s, modified=NOW()
(self.doc.customer_name, self.doc.name)) where customer=%s""", (self.doc.customer_name, self.doc.name))
def update_contact(self): def update_contact(self):
webnotes.conn.sql("""update `tabContact` set customer_name=%s where customer=%s""", webnotes.conn.sql("""update `tabContact` set customer_name=%s, modified=NOW()
(self.doc.customer_name, self.doc.name)) where customer=%s""", (self.doc.customer_name, self.doc.name))
def create_account_head(self): def create_account_head(self):
if self.doc.company : if self.doc.company :
@ -159,17 +159,17 @@ class DocType(TransactionBase):
rename_account_for("Customer", olddn, newdn, merge) rename_account_for("Customer", olddn, newdn, merge)
def after_rename(self, olddn, newdn, merge=False): def after_rename(self, olddn, newdn, merge=False):
condition = value = '' set_field = ''
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
webnotes.conn.set(self.doc, "customer_name", newdn) webnotes.conn.set(self.doc, "customer_name", newdn)
self.update_contact() self.update_contact()
condition = ", customer_name=%s" set_field = ", customer_name=%(newdn)s"
value = newdn self.update_customer_address(newdn, set_field)
self.update_customer_address(newdn, condition, value)
def update_customer_address(self, newdn, condition, value): def update_customer_address(self, newdn, set_field):
webnotes.conn.sql("""update `tabAddress` set address_title=%s %s webnotes.conn.sql("""update `tabAddress` set address_title=%(newdn)s
where customer=%s""" % ('%s', condition, '%s'), (newdn, value, newdn)) {set_field} where customer=%(newdn)s"""\
.format(set_field=set_field), ({"newdn": newdn}))
@webnotes.whitelist() @webnotes.whitelist()
def get_dashboard_info(customer): def get_dashboard_info(customer):

View File

@ -2,11 +2,12 @@
{ {
"creation": "2013-01-10 16:34:32", "creation": "2013-01-10 16:34:32",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-11 17:02:12", "modified": "2013-12-12 12:17:46",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"allow_rename": 1,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Master", "document_type": "Master",
"icon": "icon-map-marker", "icon": "icon-map-marker",

View File

@ -2,11 +2,12 @@
{ {
"creation": "2013-01-10 16:34:32", "creation": "2013-01-10 16:34:32",
"docstatus": 0, "docstatus": 0,
"modified": "2013-10-08 16:48:50", "modified": "2013-12-12 12:18:19",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"allow_rename": 1,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Master", "document_type": "Master",
"icon": "icon-user", "icon": "icon-user",