mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 21:29:11 +00:00
mass replace sql with webnotes.conn.sql
This commit is contained in:
@@ -32,7 +32,7 @@ class DocType:
|
||||
def validate_parent(self):
|
||||
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
||||
if self.doc.parent_account:
|
||||
par = sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
|
||||
par = webnotes.conn.sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
|
||||
from tabAccount where name =%s""", self.doc.parent_account)
|
||||
if not par:
|
||||
msgprint("Parent account does not exists", raise_exception=1)
|
||||
@@ -60,7 +60,7 @@ class DocType:
|
||||
def validate_duplicate_account(self):
|
||||
if self.doc.fields.get('__islocal') or not self.doc.name:
|
||||
company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
|
||||
if sql("""select name from tabAccount where name=%s""",
|
||||
if webnotes.conn.sql("""select name from tabAccount where name=%s""",
|
||||
(self.doc.account_name + " - " + company_abbr)):
|
||||
msgprint("Account Name: %s already exists, please rename"
|
||||
% self.doc.account_name, raise_exception=1)
|
||||
@@ -97,12 +97,12 @@ class DocType:
|
||||
|
||||
# Check if any previous balance exists
|
||||
def check_gle_exists(self):
|
||||
exists = sql("""select name from `tabGL Entry` where account = %s
|
||||
exists = webnotes.conn.sql("""select name from `tabGL Entry` where account = %s
|
||||
and ifnull(is_cancelled, 'No') = 'No'""", self.doc.name)
|
||||
return exists and exists[0][0] or ''
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return sql("""select name from `tabAccount` where parent_account = %s
|
||||
return webnotes.conn.sql("""select name from `tabAccount` where parent_account = %s
|
||||
and docstatus != 2""", self.doc.name)
|
||||
|
||||
def validate_mandatory(self):
|
||||
@@ -141,7 +141,7 @@ class DocType:
|
||||
# Get credit limit
|
||||
credit_limit_from = 'Customer'
|
||||
|
||||
cr_limit = sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
||||
cr_limit = webnotes.conn.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
||||
where t2.name=%s and t1.name = t2.master_name""", account)
|
||||
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
|
||||
if not credit_limit:
|
||||
@@ -173,7 +173,7 @@ class DocType:
|
||||
self.update_nsm_model()
|
||||
|
||||
# delete all cancelled gl entry of this account
|
||||
sql("""delete from `tabGL Entry` where account = %s and
|
||||
webnotes.conn.sql("""delete from `tabGL Entry` where account = %s and
|
||||
ifnull(is_cancelled, 'No') = 'Yes'""", self.doc.name)
|
||||
|
||||
def on_rename(self, new, old, merge=False):
|
||||
@@ -185,7 +185,7 @@ class DocType:
|
||||
|
||||
# rename account name
|
||||
new_account_name = " - ".join(parts[:-1])
|
||||
sql("update `tabAccount` set account_name = %s where name = %s", (new_account_name, old))
|
||||
webnotes.conn.sql("update `tabAccount` set account_name = %s where name = %s", (new_account_name, old))
|
||||
|
||||
if merge:
|
||||
new_name = " - ".join(parts)
|
||||
|
||||
Reference in New Issue
Block a user