def process_childs(self): docs = frappe.get_all("File", fields=["file_name", "file_url"], filters={"attached_to_name": self.dn, "attached_to_doctype": self.dt, "name": self.parent}) if not docs: frappe.msgprint(_("Add a report first."), raise_exception=True) for doc in docs: jrxml_ext = get_extension(doc.file_name) if jrxml_ext == "jrxml": #jrxml_os_path = self.path_join(self.jasper_path, doc.file_url[1:]) jrxml_os_path = self.path_join(self.jasper_path, get_file_path(doc.file_url)) xmldoc = JasperXmlReport(jrxml_os_path) if (self.ext!="properties" and self.ext != "xml"): image_path = xmldoc.get_image_path_from_jrxml(self.fname) self.file_path= self.path_join(self.compiled_path, os.path.normpath(image_path)) elif (self.ext == "xml"): xmlname = xmldoc.getProperty("XMLNAME") if xmlname: xname = xmlname + ".xml" if xname != self.fname: frappe.msgprint(_("This report does't have %s as file source." % (self.fname,)),raise_exception=True) self.file_path = self.path_join(self.compiled_path, os.path.normpath(self.fname)) else: frappe.msgprint(_("This report does't have %s as file source." % (self.fname,)),raise_exception=True) else: value = xmldoc.get_attrib("resourceBundle") if not value or value not in self.fname: frappe.msgprint(_("This report does't have %s as properties." % (self.fname,)),raise_exception=True) self.file_path = self.path_join(self.compiled_path, os.path.normpath(self.fname)) break else: frappe.msgprint(_("Add a file for this report first."),raise_exception=True)
def process_childs(self): docs = frappe.get_all("File", fields=["file_name", "file_url"], filters={"attached_to_name": self.dn, "attached_to_doctype": self.dt, "name": self.parent}) if not docs: frappe.msgprint(_("Add a report first."), raise_exception=True) for doc in docs: jrxml_ext = get_extension(doc.file_name) if jrxml_ext == "jrxml": #jrxml_os_path = self.path_join(self.jasper_path, doc.file_url[1:]) jrxml_os_path = self.path_join(self.jasper_path, get_file_path(doc.file_url)) xmldoc = JasperXmlReport(jrxml_os_path) if (self.ext!="properties" and self.ext != "xml"): image_path = xmldoc.get_image_path_from_jrxml(self.fname) self.file_path= self.path_join(self.compiled_path, os.path.normpath(image_path)) elif (self.ext == "xml"): xmlname = xmldoc.getProperty("XMLNAME") if xmlname: xname = xmlname + ".xml" if xname != self.fname: frappe.msgprint(_("This report does't have %s as file source." % (self.fname,)),raise_exception=True) self.file_path = self.path_join(self.compiled_path, os.path.normpath(self.fname)) else: frappe.msgprint(_("This report does't have %s as file source." % (self.fname,)),raise_exception=True) else: value = xmldoc.get_attrib("resourceBundle") if not value or value not in self.fname: frappe.msgprint(_("This report does't have %s as properties." % (self.fname,)),raise_exception=True) self.file_path = self.path_join(self.compiled_path, os.path.normpath(self.fname)) break else: frappe.msgprint(_("Add a file for this report first."),raise_exception=True)
def make_content_jrxml(self, name): xmldoc = JasperXmlReport(BytesIO(self.content)) xmldoc.change_subreport_expression_path() self.scriptlet = xmldoc.get_attrib("scriptletClass") #TODO if not self.scriptlet: pass xmldoc.change_path_images() xmldoc.setProperty("parent", self.parent) xmldoc.setProperty("jasperId", name) self.content = xmldoc.toString()
def make_content_jrxml(self, name): #import re xmldoc = JasperXmlReport(BytesIO(self.content)) xmldoc.change_subreport_expression_path() self.scriptlet = xmldoc.get_attrib("scriptletClass") #TODO if not self.scriptlet: pass xmldoc.change_path_images() xmldoc.setProperty("parent", self.parent) xmldoc.setProperty("jasperId", name) self.content = xmldoc.toString()