diff --git a/webnotes/core/doctype/notification_count/notification_count.py b/webnotes/core/doctype/notification_count/notification_count.py
index 09b3efc097..2512099f60 100644
--- a/webnotes/core/doctype/notification_count/notification_count.py
+++ b/webnotes/core/doctype/notification_count/notification_count.py
@@ -18,7 +18,7 @@ def get_notifications():
open_count_module = {}
notification_count = dict(webnotes.conn.sql("""select for_doctype, open_count
- from `tabNotification Count` where owner=%s""", webnotes.session.user))
+ from `tabNotification Count` where owner=%s""", (webnotes.session.user,)))
for d in config.for_doctype:
if d in can_read:
@@ -51,7 +51,7 @@ def get_notifications():
def delete_notification_count_for(doctype):
if webnotes.flags.in_import: return
- webnotes.conn.sql("""delete from `tabNotification Count` where for_doctype = %s""", doctype)
+ webnotes.conn.sql("""delete from `tabNotification Count` where for_doctype = %s""", (doctype,))
def delete_event_notification_count():
delete_notification_count_for("Event")
diff --git a/webnotes/core/doctype/profile/profile.py b/webnotes/core/doctype/profile/profile.py
index 8b4842583a..8c00402967 100644
--- a/webnotes/core/doctype/profile/profile.py
+++ b/webnotes/core/doctype/profile/profile.py
@@ -220,17 +220,17 @@ Thank you,
webnotes.local.login_manager.logout(user=self.doc.name)
# delete their password
- webnotes.conn.sql("""delete from __Auth where user=%s""", self.doc.name)
+ webnotes.conn.sql("""delete from __Auth where user=%s""", (self.doc.name,))
# delete todos
- webnotes.conn.sql("""delete from `tabToDo` where owner=%s""", self.doc.name)
+ webnotes.conn.sql("""delete from `tabToDo` where owner=%s""", (self.doc.name,))
webnotes.conn.sql("""update tabToDo set assigned_by=null where assigned_by=%s""",
- self.doc.name)
+ (self.doc.name,))
# delete events
webnotes.conn.sql("""delete from `tabEvent` where owner=%s
- and event_type='Private'""", self.doc.name)
- webnotes.conn.sql("""delete from `tabEvent User` where person=%s""", self.doc.name)
+ and event_type='Private'""", (self.doc.name,))
+ webnotes.conn.sql("""delete from `tabEvent User` where person=%s""", (self.doc.name,))
# delete messages
webnotes.conn.sql("""delete from `tabComment` where comment_doctype='Message'
@@ -315,7 +315,7 @@ def get_perm_info(arg=None):
return webnotes.conn.sql("""select parent, permlevel, `read`, `write`, submit,
cancel, amend from tabDocPerm where role=%s
and docstatus<2 order by parent, permlevel""",
- webnotes.form_dict['role'], as_dict=1)
+ (webnotes.form_dict['role'],), as_dict=1)
@webnotes.whitelist(allow_guest=True)
def update_password(new_password, key=None, old_password=None):
@@ -368,7 +368,7 @@ def reset_password(user):
if user in ["demo@erpnext.com", "Administrator"]:
return "Not allowed"
- if webnotes.conn.sql("""select name from tabProfile where name=%s""", user):
+ if webnotes.conn.sql("""select name from tabProfile where name=%s""", (user,)):
# Hack!
webnotes.session["user"] = "Administrator"
profile = webnotes.bean("Profile", user)
diff --git a/webnotes/core/doctype/profile/test_profile.py b/webnotes/core/doctype/profile/test_profile.py
index fe7cdd0fd8..fb3129c73c 100644
--- a/webnotes/core/doctype/profile/test_profile.py
+++ b/webnotes/core/doctype/profile/test_profile.py
@@ -20,7 +20,7 @@ class TestProfile(unittest.TestCase):
delete_doc("Profile", "_test@example.com")
self.assertTrue(not webnotes.conn.sql("""select * from `tabToDo` where owner=%s""",
- "_test@example.com"))
+ ("_test@example.com",)))
from webnotes.core.doctype.role.test_role import test_records as role_records
webnotes.bean(copy=role_records[1]).insert()
diff --git a/webnotes/core/notifications.py b/webnotes/core/notifications.py
index 8f10c3603f..ec358efcf6 100644
--- a/webnotes/core/notifications.py
+++ b/webnotes/core/notifications.py
@@ -41,4 +41,4 @@ def get_unread_messages():
WHERE comment_doctype IN ('My Company', 'Message')
AND comment_docname = %s
AND ifnull(docstatus,0)=0
- """, webnotes.user.name)[0][0]
\ No newline at end of file
+ """, (webnotes.user.name,))[0][0]
\ No newline at end of file
diff --git a/webnotes/db.py b/webnotes/db.py
index 8be719eb05..b6e08c8eaa 100644
--- a/webnotes/db.py
+++ b/webnotes/db.py
@@ -469,7 +469,7 @@ class Database:
if dt==dn:
return True # single always exists (!)
try:
- return self.sql('select name from `tab%s` where name=%s' % (dt, '%s'), dn)
+ return self.sql('select name from `tab%s` where name=%s' % (dt, '%s'), (dn,))
except:
return None
elif isinstance(dt, dict) and dt.get('doctype'):
diff --git a/webnotes/defaults.py b/webnotes/defaults.py
index 6efbbe389f..66eef61e45 100644
--- a/webnotes/defaults.py
+++ b/webnotes/defaults.py
@@ -34,7 +34,7 @@ def get_restrictions(user=None):
def build_restrictions(user):
out = {}
for key, value in webnotes.conn.sql("""select defkey, defvalue
- from tabDefaultValue where parent=%s and parenttype='Restriction'""", user):
+ from tabDefaultValue where parent=%s and parenttype='Restriction'""", (user,)):
out.setdefault(key, [])
out[key].append(value)
return out
@@ -133,7 +133,7 @@ def get_defaults_for(parent="Control Panel"):
defaults = webnotes.cache().get_value("__defaults:" + parent)
if not defaults:
res = webnotes.conn.sql("""select defkey, defvalue from `tabDefaultValue`
- where parent = %s order by creation""", parent, as_dict=1)
+ where parent = %s order by creation""", (parent,), as_dict=1)
defaults = webnotes._dict({})
for d in res:
diff --git a/webnotes/model/db_schema.py b/webnotes/model/db_schema.py
index 4d42d74d62..9963cd3a4e 100644
--- a/webnotes/model/db_schema.py
+++ b/webnotes/model/db_schema.py
@@ -100,7 +100,7 @@ class DbTable:
try:
custom_fl = webnotes.conn.sql("""\
SELECT * FROM `tabCustom Field`
- WHERE dt = %s AND docstatus < 2""", self.doctype, as_dict=1)
+ WHERE dt = %s AND docstatus < 2""", (self.doctype,), as_dict=1)
if custom_fl: fl += custom_fl
except Exception, e:
if e.args[0]!=1146: # ignore no custom field
@@ -393,7 +393,7 @@ def updatedb(dt):
* updates columns
* updates indices
"""
- res = webnotes.conn.sql("select ifnull(issingle, 0) from tabDocType where name=%s", dt)
+ res = webnotes.conn.sql("select ifnull(issingle, 0) from tabDocType where name=%s", (dt,))
if not res:
raise Exception, 'Wrong doctype "%s" in updatedb' % dt
diff --git a/webnotes/model/delete_doc.py b/webnotes/model/delete_doc.py
index fe14b2c616..24002b34d7 100644
--- a/webnotes/model/delete_doc.py
+++ b/webnotes/model/delete_doc.py
@@ -36,10 +36,10 @@ def delete_doc(doctype=None, name=None, doclist = None, force=0, ignore_doctypes
try:
tablefields = webnotes.model.meta.get_table_fields(doctype)
- webnotes.conn.sql("delete from `tab%s` where name=%s" % (doctype, "%s"), name)
+ webnotes.conn.sql("delete from `tab%s` where name=%s" % (doctype, "%s"), (name,))
for t in tablefields:
if t[0] not in ignore_doctypes:
- webnotes.conn.sql("delete from `tab%s` where parent = %s" % (t[0], '%s'), name)
+ webnotes.conn.sql("delete from `tab%s` where parent = %s" % (t[0], '%s'), (name,))
except Exception, e:
if e.args[0]==1451:
webnotes.msgprint("Cannot delete %s '%s' as it is referenced in another record. You must delete the referred record first" % (doctype, name))
diff --git a/webnotes/model/doc.py b/webnotes/model/doc.py
index b8d0a7dc80..27b8aa3903 100755
--- a/webnotes/model/doc.py
+++ b/webnotes/model/doc.py
@@ -375,7 +375,7 @@ class Document:
if '\n' in dt:
dt = dt.split('\n')[0]
tmp = webnotes.conn.sql("""SELECT name FROM `tab%s`
- WHERE name = %s""" % (dt, '%s'), dn)
+ WHERE name = %s""" % (dt, '%s'), (dn,))
return tmp and tmp[0][0] or ''# match case
def _update_values(self, issingle, link_list, ignore_fields=0, keep_timestamps=False):
@@ -441,7 +441,7 @@ class Document:
"""update parent type and parent field, if not explicitly specified"""
tmp = webnotes.conn.sql("""select parent, fieldname from tabDocField
- where fieldtype='Table' and options=%s""", self.doctype)
+ where fieldtype='Table' and options=%s""", (self.doctype,))
if len(tmp)==0:
raise Exception, 'Incomplete parent info in child table (%s, %s)' \
@@ -587,15 +587,15 @@ def make_autoname(key, doctype=''):
def getseries(key, digits, doctype=''):
# series created ?
- current = webnotes.conn.sql("select `current` from `tabSeries` where name=%s for update", key)
+ current = webnotes.conn.sql("select `current` from `tabSeries` where name=%s for update", (key,))
if current and current[0][0] is not None:
current = current[0][0]
# yes, update it
- webnotes.conn.sql("update tabSeries set current = current+1 where name=%s", key)
+ webnotes.conn.sql("update tabSeries set current = current+1 where name=%s", (key,))
current = cint(current) + 1
else:
# no, create it
- webnotes.conn.sql("insert into tabSeries (name, current) values (%s, 1)", key)
+ webnotes.conn.sql("insert into tabSeries (name, current) values (%s, 1)", (key,))
current = 1
return ('%0'+str(digits)+'d') % current
@@ -633,7 +633,7 @@ def check_page_perm(doc):
if doc.publish:
return
- if not webnotes.conn.sql("select name from `tabPage Role` where parent=%s and role='Guest'", doc.name):
+ if not webnotes.conn.sql("select name from `tabPage Role` where parent=%s and role='Guest'", (doc.name,)):
webnotes.response['403'] = 1
raise webnotes.PermissionError, '[WNF] No read permission for %s %s' % ('Page', doc.name)
@@ -669,7 +669,7 @@ def get(dt, dn='', with_children = 1, from_controller = 0):
def getsingle(doctype):
"""get single doc as dict"""
- dataset = webnotes.conn.sql("select field, value from tabSingles where doctype=%s", doctype)
+ dataset = webnotes.conn.sql("select field, value from tabSingles where doctype=%s", (doctype,))
return dict(dataset)
def copy_common_fields(from_doc, to_doc):
@@ -685,7 +685,7 @@ def copy_common_fields(from_doc, to_doc):
def validate_name(doctype, name, case=None, merge=False):
if not merge:
- if webnotes.conn.sql('select name from `tab%s` where name=%s' % (doctype,'%s'), name):
+ if webnotes.conn.sql('select name from `tab%s` where name=%s' % (doctype,'%s'), (name,)):
raise NameError, 'Name %s already exists' % name
# no name
diff --git a/webnotes/model/doctype.py b/webnotes/model/doctype.py
index 8adffeed90..b13e672a2b 100644
--- a/webnotes/model/doctype.py
+++ b/webnotes/model/doctype.py
@@ -132,7 +132,7 @@ def sort_fields(doclist):
def apply_property_setters(doctype, doclist):
for ps in webnotes.conn.sql("""select * from `tabProperty Setter` where
- doc_type=%s""", doctype, as_dict=1):
+ doc_type=%s""", (doctype,), as_dict=1):
if ps['doctype_or_field']=='DocType':
if ps.get('property_type', None) in ('Int', 'Check'):
ps['value'] = cint(ps['value'])
@@ -149,7 +149,7 @@ def apply_property_setters(doctype, doclist):
def add_custom_fields(doctype, doclist):
try:
res = webnotes.conn.sql("""SELECT * FROM `tabCustom Field`
- WHERE dt = %s AND docstatus < 2""", doctype, as_dict=1)
+ WHERE dt = %s AND docstatus < 2""", (doctype,), as_dict=1)
except Exception, e:
if e.args[0]==1146:
return doclist
@@ -251,7 +251,7 @@ def clear_cache(doctype=None):
# clear all parent doctypes
for dt in webnotes.conn.sql("""select parent from tabDocField
- where fieldtype="Table" and options=%s""", doctype):
+ where fieldtype="Table" and options=%s""", (doctype,)):
clear_single(dt[0])
# clear all notifications
@@ -312,7 +312,7 @@ def expand_selects(doclist):
def add_print_formats(doclist):
print_formats = webnotes.conn.sql("""select * FROM `tabPrint Format`
- WHERE doc_type=%s AND docstatus<2""", doclist[0].name, as_dict=1)
+ WHERE doc_type=%s AND docstatus<2""", (doclist[0].name,), as_dict=1)
for pf in print_formats:
doclist.append(webnotes.model.doc.Document('Print Format', fielddata=pf))
@@ -334,7 +334,7 @@ def get_link_fields(doctype):
def add_validators(doctype, doclist):
for validator in webnotes.conn.sql("""select name from `tabDocType Validator` where
- for_doctype=%s""", doctype, as_dict=1):
+ for_doctype=%s""", (doctype,), as_dict=1):
doclist.extend(webnotes.get_doclist('DocType Validator', validator.name))
def add_search_fields(doclist):
diff --git a/webnotes/model/rename_doc.py b/webnotes/model/rename_doc.py
index a8e3ec8054..cd4c5f58b0 100644
--- a/webnotes/model/rename_doc.py
+++ b/webnotes/model/rename_doc.py
@@ -149,7 +149,7 @@ def get_link_fields(doctype):
df.parent not like "old%%%%" and df.parent != '0' and
((df.options=%s and df.fieldtype='Link') or
(df.options='link:%s' and df.fieldtype='Select'))""" \
- % ('%s', doctype), doctype, as_dict=1)
+ % ('%s', doctype), (doctype,), as_dict=1)
# get link fields from tabCustom Field
custom_link_fields = webnotes.conn.sql("""\
@@ -161,7 +161,7 @@ def get_link_fields(doctype):
df.dt not like "old%%%%" and df.dt != '0' and
((df.options=%s and df.fieldtype='Link') or
(df.options='link:%s' and df.fieldtype='Select'))""" \
- % ('%s', doctype), doctype, as_dict=1)
+ % ('%s', doctype), (doctype,), as_dict=1)
# add custom link fields list to link fields list
link_fields += custom_link_fields
@@ -176,7 +176,7 @@ def get_link_fields(doctype):
ps.property_type='options' and
ps.field_name is not null and
(ps.value=%s or ps.value='link:%s')""" \
- % ('%s', doctype), doctype, as_dict=1)
+ % ('%s', doctype), (doctype,), as_dict=1)
link_fields += property_setter_link_fields
@@ -211,7 +211,7 @@ def get_select_fields(old, new):
df.parent != %s and df.fieldtype = 'Select' and
df.options not like "link:%%%%" and
(df.options like "%%%%%s%%%%")""" \
- % ('%s', old), new, as_dict=1)
+ % ('%s', old), (new,), as_dict=1)
# get link fields from tabCustom Field
custom_select_fields = webnotes.conn.sql("""\
@@ -224,7 +224,7 @@ def get_select_fields(old, new):
df.dt != %s and df.fieldtype = 'Select' and
df.options not like "link:%%%%" and
(df.options like "%%%%%s%%%%")""" \
- % ('%s', old), new, as_dict=1)
+ % ('%s', old), (new,), as_dict=1)
# add custom link fields list to link fields list
select_fields += custom_select_fields
@@ -241,7 +241,7 @@ def get_select_fields(old, new):
ps.field_name is not null and
ps.value not like "link:%%%%" and
(ps.value like "%%%%%s%%%%")""" \
- % ('%s', old), new, as_dict=1)
+ % ('%s', old), (new,), as_dict=1)
select_fields += property_setter_select_fields
@@ -275,11 +275,11 @@ def update_select_field_values(old, new):
def update_parenttype_values(old, new):
child_doctypes = webnotes.conn.sql("""\
select options, fieldname from `tabDocField`
- where parent=%s and fieldtype='Table'""", new, as_dict=1)
+ where parent=%s and fieldtype='Table'""", (new,), as_dict=1)
custom_child_doctypes = webnotes.conn.sql("""\
select options, fieldname from `tabCustom Field`
- where dt=%s and fieldtype='Table'""", new, as_dict=1)
+ where dt=%s and fieldtype='Table'""", (new,), as_dict=1)
child_doctypes += custom_child_doctypes
fields = [d['fieldname'] for d in child_doctypes]
@@ -288,7 +288,7 @@ def update_parenttype_values(old, new):
select value as options from `tabProperty Setter`
where doc_type=%s and property='options' and
field_name in ("%s")""" % ('%s', '", "'.join(fields)),
- new)
+ (new,))
child_doctypes += property_setter_child_doctypes
child_doctypes = (d['options'] for d in child_doctypes)
diff --git a/webnotes/profile.py b/webnotes/profile.py
index db2e8b6290..600790b126 100644
--- a/webnotes/profile.py
+++ b/webnotes/profile.py
@@ -148,7 +148,7 @@ class Profile:
def load_profile(self):
d = webnotes.conn.sql("""select email, first_name, last_name,
email_signature, background_image, user_type, language
- from tabProfile where name = %s""", self.name, as_dict=1)[0]
+ from tabProfile where name = %s""", (self.name,), as_dict=1)[0]
if not self.can_read:
self.build_permissions()
@@ -169,7 +169,7 @@ class Profile:
return d
def get_user_fullname(user):
- fullname = webnotes.conn.sql("SELECT CONCAT_WS(' ', first_name, last_name) FROM `tabProfile` WHERE name=%s", user)
+ fullname = webnotes.conn.sql("SELECT CONCAT_WS(' ', first_name, last_name) FROM `tabProfile` WHERE name=%s", (user,))
return fullname and fullname[0][0] or ''
def get_system_managers(only_name=False):
@@ -218,7 +218,7 @@ def get_roles(username=None, with_standard=True):
return ['Guest']
roles = [r[0] for r in webnotes.conn.sql("""select role from tabUserRole
- where parent=%s and role!='All'""", username)] + ['All']
+ where parent=%s and role!='All'""", (username,))] + ['All']
# filter standard if required
if not with_standard:
diff --git a/webnotes/sessions.py b/webnotes/sessions.py
index 892e09431f..ef5b800e2c 100644
--- a/webnotes/sessions.py
+++ b/webnotes/sessions.py
@@ -35,14 +35,14 @@ def clear_cache(user=None):
# clear notifications
if webnotes.flags.in_install_app!="webnotes":
- webnotes.conn.sql("""delete from `tabNotification Count` where owner=%s""", user)
+ webnotes.conn.sql("""delete from `tabNotification Count` where owner=%s""", (user,))
if webnotes.session:
if user==webnotes.session.user and webnotes.session.sid:
cache.delete_value("session:" + webnotes.session.sid)
else:
for sid in webnotes.conn.sql_list("""select sid from tabSessions
- where user=%s""", user):
+ where user=%s""", (user,)):
cache.delete_value("session:" + sid)
webnotes.defaults.clear_cache(user)
@@ -56,12 +56,12 @@ def clear_cache(user=None):
def clear_sessions(user=None, keep_current=False):
if not user:
user = webnotes.session.user
- for sid in webnotes.conn.sql("""select sid from tabSessions where user=%s""", user):
+ for sid in webnotes.conn.sql("""select sid from tabSessions where user=%s""", (user,)):
if keep_current and webnotes.session.sid==sid[0]:
pass
else:
webnotes.cache().delete_value("session:" + sid[0])
- webnotes.conn.sql("""delete from tabSessions where sid=%s""", sid[0])
+ webnotes.conn.sql("""delete from tabSessions where sid=%s""", (sid[0],))
def get():
"""get session boot info"""
@@ -211,7 +211,7 @@ class Session:
def delete_session(self):
webnotes.cache().delete_value("session:" + self.sid)
- r = webnotes.conn.sql("""delete from tabSessions where sid=%s""", self.sid)
+ r = webnotes.conn.sql("""delete from tabSessions where sid=%s""", (self.sid,))
def start_as_guest(self):
"""all guests share the same 'Guest' session"""
diff --git a/webnotes/templates/includes/footer_extension.html b/webnotes/templates/includes/footer_extension.html
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/webnotes/templates/includes/footer_powered.html b/webnotes/templates/includes/footer_powered.html
new file mode 100644
index 0000000000..f4e72f32c0
--- /dev/null
+++ b/webnotes/templates/includes/footer_powered.html
@@ -0,0 +1 @@
+Built on Web Notes
\ No newline at end of file
diff --git a/webnotes/utils/email_lib/bulk.py b/webnotes/utils/email_lib/bulk.py
index dcea66389b..c4ea596c46 100644
--- a/webnotes/utils/email_lib/bulk.py
+++ b/webnotes/utils/email_lib/bulk.py
@@ -61,7 +61,7 @@ def send(recipients=None, sender=None, doctype='Profile', email_field='email',
for r in filter(None, list(set(recipients))):
rdata = webnotes.conn.sql("""select * from `tab%s` where %s=%s""" % (doctype,
- email_field, '%s'), r, as_dict=1)
+ email_field, '%s'), (r,), as_dict=1)
doc = rdata and rdata[0] or {}
@@ -95,7 +95,7 @@ def unsubscribe():
email = webnotes.form_dict.get('email')
webnotes.conn.sql("""update `tab%s` set unsubscribed=1
- where `%s`=%s""" % (doctype, field, '%s'), email)
+ where `%s`=%s""" % (doctype, field, '%s'), (email,))
if not webnotes.form_dict.get("from_test"):
webnotes.conn.commit()
@@ -129,13 +129,13 @@ def flush(from_test=False):
break
webnotes.conn.sql("""update `tabBulk Email` set status='Sending' where name=%s""",
- email["name"], auto_commit=auto_commit)
+ (email["name"],), auto_commit=auto_commit)
try:
if not from_test:
smptserver.sess.sendmail(email["sender"], email["recipient"], email["message"])
webnotes.conn.sql("""update `tabBulk Email` set status='Sent' where name=%s""",
- email["name"], auto_commit=auto_commit)
+ (email["name"],), auto_commit=auto_commit)
except Exception, e:
webnotes.conn.sql("""update `tabBulk Email` set status='Error', error=%s
diff --git a/webnotes/website/doctype/blog_post/blog_post.py b/webnotes/website/doctype/blog_post/blog_post.py
index 31428a1803..2926790097 100644
--- a/webnotes/website/doctype/blog_post/blog_post.py
+++ b/webnotes/website/doctype/blog_post/blog_post.py
@@ -26,7 +26,7 @@ class DocType(WebsiteGenerator):
# update posts
webnotes.conn.sql("""update tabBlogger set posts=(select count(*) from `tabBlog Post`
where ifnull(blogger,'')=tabBlogger.name)
- where name=%s""", self.doc.blogger)
+ where name=%s""", (self.doc.blogger,))
def on_update(self):
WebsiteGenerator.on_update(self)
@@ -56,7 +56,7 @@ class DocType(WebsiteGenerator):
self.doc.comment_list = webnotes.conn.sql("""\
select comment, comment_by_fullname, creation
from `tabComment` where comment_doctype="Blog Post"
- and comment_docname=%s order by creation""", self.doc.name, as_dict=1) or []
+ and comment_docname=%s order by creation""", (self.doc.name,), as_dict=1) or []
def clear_blog_cache():
diff --git a/webnotes/website/doctype/blog_post/test_blog_post.py b/webnotes/website/doctype/blog_post/test_blog_post.py
index d8cb3d3761..474b2da74f 100644
--- a/webnotes/website/doctype/blog_post/test_blog_post.py
+++ b/webnotes/website/doctype/blog_post/test_blog_post.py
@@ -66,8 +66,10 @@ class TestBlogPost(unittest.TestCase):
def test_restriction_in_report(self):
webnotes.defaults.add_default("Blog Category", "_Test Blog Category 1", "test1@example.com",
"Restriction")
-
+ webnotes.local.reportview_doctypes = {}
+
names = [d.name for d in webnotes.get_list("Blog Post", fields=["name", "blog_category"])]
+
self.assertTrue("_test-blog-post-1" in names)
self.assertFalse("_test-blog-post" in names)
diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py
index 9d7ed6e3cf..0c8a1b2389 100644
--- a/webnotes/widgets/reportview.py
+++ b/webnotes/widgets/reportview.py
@@ -111,6 +111,9 @@ def load_doctypes():
for t in webnotes.local.reportview_tables:
if t.startswith('`'):
doctype = t[4:-1]
+ if webnotes.local.reportview_doctypes.get(doctype):
+ continue
+
if not webnotes.has_permission(doctype):
raise webnotes.PermissionError, doctype
webnotes.local.reportview_doctypes[doctype] = webnotes.model.doctype.get(doctype)
@@ -172,8 +175,7 @@ def build_filter_conditions(filters, conditions):
if not tname in webnotes.local.reportview_tables:
webnotes.local.reportview_tables.append(tname)
- if not hasattr(webnotes.local, "reportview_doctypes"):
- load_doctypes()
+ load_doctypes()
# prepare in condition
if f[2] in ['in', 'not in']:
@@ -202,10 +204,10 @@ def build_match_conditions(doctype, fields=None, as_condition=True):
match_filters = {}
match_conditions = []
- if not getattr(webnotes.local, "reportview_tables", None) \
- or not getattr(webnotes.local, "reportview_doctypes", None):
+ if not getattr(webnotes.local, "reportview_tables", None):
webnotes.local.reportview_tables = get_tables(doctype, fields)
- load_doctypes()
+
+ load_doctypes()
# get restrictions
restrictions = webnotes.defaults.get_restrictions()