Ejemplo n.º 1
0
def build_from_query_report():
	"""make locale for the query reports from database and the framework js and py files"""
	import re
	for item in webnotes.conn.sql("""select name, report_name,ref_doctype, query 
			from `tabReport`""", as_dict=1):
		messages_js, messages_py = [], []

		if item:
			messages_js.append(item.report_name)
			messages_py.append(item.report_name)
			# get the messages from the query using the regex :
			# if we have the string "Production Date:Date:180" in the query then the regex will search for string between " and : .
			# the regex will take "Production Date" and store them into messages
			if item.query :
				messages_query = re.findall('"([^:,^"]*):', item.query)
				messages_js += messages_query
				messages_py += messages_query
			
			module = get_doctype_module(item.ref_doctype)		
			if module :
				doctype_path = get_doc_path(module, "Report", item.name)
				if os.path.exists(doctype_path):
					for (basepath, folders, files) in os.walk(doctype_path):
						if 'locale' in folders: folders.remove('locale')
						for fname in files:
							if fname.endswith('.js'):
								messages_js += get_message_list(os.path.join(basepath, fname))	
							if fname.endswith('.py'):
								messages_py += get_message_list(os.path.join(basepath, fname))
						break			
					write_messages_file(doctype_path, messages_js, 'js')
					write_messages_file(doctype_path, messages_py, 'py')
Ejemplo n.º 2
0
def get_server_obj(doc, doclist = [], basedoctype = ''):
	# for test
	import webnotes
	from webnotes.modules import scrub, get_doctype_module
	from core.doctype.custom_script.custom_script import get_custom_server_script

	# get doctype details
	module = get_doctype_module(doc.doctype) or "core"
		
	if not module:
		return
		
	DocType = get_doctype_class(doc.doctype, module)
	
	if webnotes.flags.in_import:
		return DocType(doc, doclist)

	# custom?
	custom_script = get_custom_server_script(doc.doctype)

	if custom_script:
		opts = {"DocType": DocType}
		exec custom_script in opts
		return opts["CustomDocType"](doc, doclist)
		
	else:
		return DocType(doc, doclist)
Ejemplo n.º 3
0
def build_from_query_report():
	"""make locale for the query reports from database and the framework js and py files"""
	import re
	for item in webnotes.conn.sql("""select name, report_name,ref_doctype, query 
			from `tabReport`""", as_dict=1):
		messages_js, messages_py = [], []

		if item:
			messages_js.append(item.report_name)
			messages_py.append(item.report_name)
			# get the messages from the query using the regex :
			# if we have the string "Production Date:Date:180" in the query then the regex will search for string between " and : .
			# the regex will take "Production Date" and store them into messages
			if item.query :
				messages_query = re.findall('"([^:,^"]*):', item.query)
				messages_js += messages_query
				messages_py += messages_query
			
			module = get_doctype_module(item.ref_doctype)		
			if module :
				doctype_path = get_doc_path(module, "Report", item.name)
				if os.path.exists(doctype_path):
					for (basepath, folders, files) in os.walk(doctype_path):
						if 'locale' in folders: folders.remove('locale')
						for fname in files:
							if fname.endswith('.js'):
								messages_js += get_message_list(os.path.join(basepath, fname))	
							if fname.endswith('.py'):
								messages_py += get_message_list(os.path.join(basepath, fname))
						break			
					write_messages_file(doctype_path, messages_js, 'js')
					write_messages_file(doctype_path, messages_py, 'py')
Ejemplo n.º 4
0
def get_server_obj(doc, doclist = [], basedoctype = ''):
	# for test
	import webnotes
	from webnotes.modules import scrub, get_doctype_module
	from core.doctype.custom_script.custom_script import get_custom_server_script

	# get doctype details
	module = get_doctype_module(doc.doctype) or "core"
		
	if not module:
		return
		
	DocType = get_doctype_class(doc.doctype, module)

	# custom?
	custom_script = get_custom_server_script(doc.doctype)
		
	if custom_script:
		global custom_class
				
		exec custom_class + custom_script.replace('\t','  ') in locals()
			
		return CustomDocType(doc, doclist)
	else:
		return DocType(doc, doclist)
Ejemplo n.º 5
0
def load_doctype_module(doctype, module=None, prefix=""):
	import webnotes
	from webnotes.modules import scrub, get_doctype_module
	if not module:
		module = get_doctype_module(doctype) or "core"
	try:
		module = __import__(get_module_name(doctype, module, prefix), fromlist=[''])
		return module
	except ImportError, e:
		# webnotes.errprint(webnotes.getTraceback())
		return None
Ejemplo n.º 6
0
def load_doctype_module(doctype, module=None, prefix=""):
	import webnotes
	from webnotes.modules import scrub, get_doctype_module
	if not module:
		module = get_doctype_module(doctype) or "core"
	try:
		module = __import__(get_module_name(doctype, module, prefix), fromlist=[''])
		return module
	except ImportError, e:
		# webnotes.errprint(webnotes.getTraceback())
		return None
Ejemplo n.º 7
0
def get_server_obj(doc, doclist = [], basedoctype = ''):
	# for test
	import webnotes
	from webnotes.modules import scrub, get_doctype_module
	from webnotes.plugins import get_code_and_execute

	# get doctype details
	module = get_doctype_module(doc.doctype) or "core"
		
	if not module:
		return
		
	DocType = get_doctype_class(doc.doctype, module)
	
	if webnotes.flags.in_import:
		return DocType(doc, doclist)

	# custom?
	namespace = {"DocType": DocType}
	get_code_and_execute(module, "DocType", doc.doctype, namespace=namespace)
	if namespace.get("CustomDocType"):
		return namespace["CustomDocType"](doc, doclist)
	else:
		return DocType(doc, doclist)
Ejemplo n.º 8
0
def get_server_obj(doc, doclist=[], basedoctype=''):
    # for test
    import webnotes
    from webnotes.modules import scrub, get_doctype_module
    from core.doctype.custom_script.custom_script import get_custom_server_script

    # get doctype details
    module = get_doctype_module(doc.doctype) or "core"

    if not module:
        return

    DocType = get_doctype_class(doc.doctype, module)

    # custom?
    custom_script = get_custom_server_script(doc.doctype)
    if custom_script:
        global custom_class

        exec custom_class + custom_script.replace('\t', '  ') in locals()

        return CustomDocType(doc, doclist)
    else:
        return DocType(doc, doclist)
Ejemplo n.º 9
0
def load_doctype_module(doctype, module=None, prefix=""):
	if not module:
		module = get_doctype_module(doctype)
	return webnotes.get_module(get_module_name(doctype, module, prefix))
Ejemplo n.º 10
0
def get_server_obj(doc, doclist = [], basedoctype = ''):
	# for test
	module = get_doctype_module(doc.doctype)
	return load_doctype_module(doc.doctype, module).DocType(doc, doclist)