mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
mass replace sql with webnotes.conn.sql
This commit is contained in:
@@ -35,25 +35,24 @@ class DocType(TransactionBase):
|
||||
self.validate_primary_contact()
|
||||
|
||||
def validate_primary_contact(self):
|
||||
sql = webnotes.conn.sql
|
||||
if self.doc.is_primary_contact == 1:
|
||||
if self.doc.customer:
|
||||
sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
|
||||
webnotes.conn.sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
|
||||
elif self.doc.supplier:
|
||||
sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))
|
||||
webnotes.conn.sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))
|
||||
elif self.doc.sales_partner:
|
||||
sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
|
||||
webnotes.conn.sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
|
||||
else:
|
||||
if self.doc.customer:
|
||||
if not sql("select name from tabContact where is_primary_contact=1 and customer = '%s'" % (self.doc.customer)):
|
||||
if not webnotes.conn.sql("select name from tabContact where is_primary_contact=1 and customer = '%s'" % (self.doc.customer)):
|
||||
self.doc.is_primary_contact = 1
|
||||
elif self.doc.supplier:
|
||||
if not sql("select name from tabContact where is_primary_contact=1 and supplier = '%s'" % (self.doc.supplier)):
|
||||
if not webnotes.conn.sql("select name from tabContact where is_primary_contact=1 and supplier = '%s'" % (self.doc.supplier)):
|
||||
self.doc.is_primary_contact = 1
|
||||
elif self.doc.sales_partner:
|
||||
if not sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
|
||||
if not webnotes.conn.sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
|
||||
self.doc.is_primary_contact = 1
|
||||
|
||||
def on_trash(self):
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set contact='' where contact=%s""",
|
||||
self.doc.name)
|
||||
self.doc.name)
|
||||
|
||||
@@ -48,7 +48,7 @@ class DocType:
|
||||
def get_contact_number(self, arg):
|
||||
"returns mobile number of the contact"
|
||||
args = load_json(arg)
|
||||
number = sql("""select mobile_no, phone from tabContact where name=%s and %s=%s""" %
|
||||
number = webnotes.conn.sql("""select mobile_no, phone from tabContact where name=%s and %s=%s""" %
|
||||
('%s', args['key'], '%s'), (args['contact_name'], args['value']))
|
||||
return number and (number[0][0] or number[0][1]) or ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user