Merge branch 'latest' of github.com:webnotes/wnframework into latest
This commit is contained in:
commit
141c959cd5
6 changed files with 18 additions and 17 deletions
|
|
@ -6,7 +6,6 @@ from webnotes.model.doc import Document
|
|||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
|
@ -19,7 +18,7 @@ class DocType:
|
|||
|
||||
def on_update(self):
|
||||
# clear cache on save
|
||||
sql("delete from __SessionCache")
|
||||
webnotes.conn.sql("delete from __SessionCache")
|
||||
|
||||
def upload_many(self,form):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -5,11 +5,8 @@ from webnotes.utils import cint, cstr, flt, formatdate, now
|
|||
from webnotes.model.doc import Document
|
||||
from webnotes import msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
|
@ -18,7 +15,7 @@ class DocType:
|
|||
# -----------
|
||||
def get_fields_label(self):
|
||||
label_name = []
|
||||
for i in sql("SELECT idx, label FROM tabDocField WHERE parent = '%s' and ifnull(hidden,0) = 0 and fieldname != '%s' order by idx" % (self.doc.dt, cstr(self.doc.fieldname))): i[1] and i[0] and label_name.append(i[1]+' - '+cstr(i[0]))
|
||||
for i in webnotes.conn.sql("SELECT idx, label FROM tabDocField WHERE parent = '%s' and ifnull(hidden,0) = 0 and fieldname != '%s' order by idx" % (self.doc.dt, cstr(self.doc.fieldname))): i[1] and i[0] and label_name.append(i[1]+' - '+cstr(i[0]))
|
||||
return "\n".join(label_name)
|
||||
|
||||
|
||||
|
|
@ -34,12 +31,12 @@ class DocType:
|
|||
# Validate Field
|
||||
# ---------------
|
||||
def validate_field(self):
|
||||
if self.doc.__islocal == 1 and sql("select name from tabDocField where parent = %s and (label = %s or fieldname = %s)" , (self.doc.dt, self.doc.label, self.doc.fieldname)):
|
||||
if self.doc.__islocal == 1 and webnotes.conn.sql("select name from tabDocField where parent = %s and (label = %s or fieldname = %s)" , (self.doc.dt, self.doc.label, self.doc.fieldname)):
|
||||
msgprint("%s field already exists in Document : %s" % (self.doc.label, self.doc.dt))
|
||||
raise Exception
|
||||
|
||||
if self.doc.fieldtype=='Link' and self.doc.options:
|
||||
if not sql("select name from tabDocType where name=%s", self.doc.options):
|
||||
if not webnotes.conn.sql("select name from tabDocType where name=%s", self.doc.options):
|
||||
msgprint("%s is not a valid Document" % self.doc.options)
|
||||
raise Exception
|
||||
|
||||
|
|
@ -48,7 +45,7 @@ class DocType:
|
|||
# -------------
|
||||
def update_field(self, df, new):
|
||||
import webnotes.model
|
||||
sql("update tabDocField set idx = idx + 1, modified = %s where parent = %s and idx > %s", (now(),self.doc.dt, self.idx))
|
||||
webnotes.conn.sql("update tabDocField set idx = idx + 1, modified = %s where parent = %s and idx > %s", (now(),self.doc.dt, self.idx))
|
||||
for k in self.doc.fields:
|
||||
if k not in webnotes.model.default_fields and k not in self.ignore_fields and not k.startswith('_'):
|
||||
df.fields[k] = self.doc.fields[k]
|
||||
|
|
@ -62,7 +59,7 @@ class DocType:
|
|||
# Add Field
|
||||
# ----------
|
||||
def add_field(self):
|
||||
field_exists = sql("select name from tabDocField where parent = %s and (label = %s or fieldname = %s)" , (self.doc.dt, self.doc.label, self.doc.fieldname))
|
||||
field_exists = webnotes.conn.sql("select name from tabDocField where parent = %s and (label = %s or fieldname = %s)" , (self.doc.dt, self.doc.label, self.doc.fieldname))
|
||||
field_exists = field_exists and field_exists[0][0] or ''
|
||||
self.ignore_fields = ['dt','trash_reason','insert_after','index','customfield1','length']
|
||||
if field_exists:
|
||||
|
|
@ -88,8 +85,8 @@ class DocType:
|
|||
# Trash
|
||||
# ------
|
||||
def on_trash(self):
|
||||
sql("update tabDocField set idx = idx - 1 where parent = %s and idx > %s" , (self.doc.dt, cint((self.doc.insert_after).split(' - ')[1])))
|
||||
sql("delete from tabDocField where parent = %s and fieldname = %s", (self.doc.dt, self.doc.fieldname))
|
||||
webnotes.conn.sql("update tabDocField set idx = idx - 1 where parent = %s and idx > %s" , (self.doc.dt, cint((self.doc.insert_after).split(' - ')[1])))
|
||||
webnotes.conn.sql("delete from tabDocField where parent = %s and fieldname = %s", (self.doc.dt, self.doc.fieldname))
|
||||
|
||||
|
||||
# Restore
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
import webnotes
|
||||
|
||||
from webnotes.utils import now, cint
|
||||
sql = webnotes.conn.sql
|
||||
msgprint = webnotes.msgprint
|
||||
|
||||
|
||||
|
|
@ -15,6 +14,7 @@ class DocType:
|
|||
self.doclist = doclist
|
||||
|
||||
def change_modified_of_parent(self):
|
||||
sql = webnotes.conn.sql
|
||||
parent_list = sql('SELECT parent from tabDocField where fieldtype="Table" and options="%s"' % self.doc.name)
|
||||
for p in parent_list:
|
||||
sql('UPDATE tabDocType SET modified="%s" WHERE `name`="%s"' % (now(), p[0]))
|
||||
|
|
@ -35,6 +35,7 @@ class DocType:
|
|||
# check if this series is not used elsewhere
|
||||
#
|
||||
def validate_series(self, autoname=None, name=None):
|
||||
sql = webnotes.conn.sql
|
||||
if not autoname: autoname = self.doc.autoname
|
||||
if not name: name = self.doc.name
|
||||
|
||||
|
|
@ -73,6 +74,7 @@ class DocType:
|
|||
|
||||
|
||||
def on_update(self):
|
||||
sql = webnotes.conn.sql
|
||||
# make schma changes
|
||||
from webnotes.model.db_schema import updatedb
|
||||
updatedb(self.doc.name)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class DocType:
|
|||
self.set_module()
|
||||
|
||||
self.autoname()
|
||||
sql("update `tabSearch Criteria` set name=%s where name=%s", (self.doc.name, old_name))
|
||||
webnotes.conn.sql("update `tabSearch Criteria` set name=%s where name=%s", (self.doc.name, old_name))
|
||||
|
||||
def rename_export(self, old_name):
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class Database:
|
|||
* Execute a `query`, with given `values`
|
||||
* returns as a dictionary if as_dict = 1
|
||||
* returns as a list of lists (with cleaned up dates and decimals) if as_list = 1
|
||||
"""
|
||||
"""
|
||||
# in transaction validations
|
||||
self.check_transaction_status(query)
|
||||
|
||||
|
|
@ -336,4 +336,7 @@ class Database:
|
|||
Close my connection
|
||||
"""
|
||||
if self._conn:
|
||||
self._cursor.close()
|
||||
self._conn.close()
|
||||
self._cursor = None
|
||||
self._conn = None
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ class Scheduler:
|
|||
import webnotes, webnotes.defs, webnotes.db
|
||||
|
||||
try:
|
||||
webnotes.conn = None
|
||||
webnotes.conn = webnotes.db.Database(user=db_name, password=webnotes.get_db_password(db_name))
|
||||
webnotes.session = {'user':'Administrator'}
|
||||
|
||||
module = '.'.join(event.split('.')[:-1])
|
||||
method = event.split('.')[-1]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue