[fix] [minor] allowed renaming for address and contact
diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py
index 503ec8a..2435d0c 100644
--- a/buying/doctype/supplier/supplier.py
+++ b/buying/doctype/supplier/supplier.py
@@ -28,11 +28,11 @@
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
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))
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))
def update_credit_days_limit(self):
@@ -164,17 +164,17 @@
rename_account_for("Supplier", olddn, newdn, merge)
def after_rename(self, olddn, newdn, merge=False):
- condition = value = ''
+ set_field = ''
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)
+ set_field = ", supplier_name=%(newdn)s"
+ self.update_supplier_address(newdn, set_field)
- 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))
+ def update_supplier_address(self, newdn, set_field):
+ webnotes.conn.sql("""update `tabAddress` set address_title=%(newdn)s
+ {set_field} where supplier=%(newdn)s"""\
+ .format(set_field=set_field), ({"newdn": newdn}))
@webnotes.whitelist()
def get_dashboard_info(supplier):
diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py
index 71116b3..49296b0 100644
--- a/selling/doctype/customer/customer.py
+++ b/selling/doctype/customer/customer.py
@@ -48,12 +48,12 @@
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))
+ webnotes.conn.sql("""update `tabAddress` set customer_name=%s, modified=NOW()
+ 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))
+ webnotes.conn.sql("""update `tabContact` set customer_name=%s, modified=NOW()
+ where customer=%s""", (self.doc.customer_name, self.doc.name))
def create_account_head(self):
if self.doc.company :
@@ -159,17 +159,17 @@
rename_account_for("Customer", olddn, newdn, merge)
def after_rename(self, olddn, newdn, merge=False):
- condition = value = ''
+ set_field = ''
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)
+ set_field = ", customer_name=%(newdn)s"
+ self.update_customer_address(newdn, set_field)
- 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))
+ def update_customer_address(self, newdn, set_field):
+ webnotes.conn.sql("""update `tabAddress` set address_title=%(newdn)s
+ {set_field} where customer=%(newdn)s"""\
+ .format(set_field=set_field), ({"newdn": newdn}))
@webnotes.whitelist()
def get_dashboard_info(customer):
diff --git a/utilities/doctype/address/address.txt b/utilities/doctype/address/address.txt
index 09be67e..5b4ada9 100644
--- a/utilities/doctype/address/address.txt
+++ b/utilities/doctype/address/address.txt
@@ -2,11 +2,12 @@
{
"creation": "2013-01-10 16:34:32",
"docstatus": 0,
- "modified": "2013-07-11 17:02:12",
+ "modified": "2013-12-12 12:17:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
+ "allow_rename": 1,
"doctype": "DocType",
"document_type": "Master",
"icon": "icon-map-marker",
diff --git a/utilities/doctype/contact/contact.txt b/utilities/doctype/contact/contact.txt
index 199aaea..1c8a5cf 100644
--- a/utilities/doctype/contact/contact.txt
+++ b/utilities/doctype/contact/contact.txt
@@ -2,11 +2,12 @@
{
"creation": "2013-01-10 16:34:32",
"docstatus": 0,
- "modified": "2013-10-08 16:48:50",
+ "modified": "2013-12-12 12:18:19",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
+ "allow_rename": 1,
"doctype": "DocType",
"document_type": "Master",
"icon": "icon-user",