def create_pdf(self, rml, localcontext = None, logo=None, title=None): if logo: self.bin_datas['logo'] = logo else: if 'logo' in self.bin_datas: del self.bin_datas['logo'] obj = render.rml(rml, localcontext, self.bin_datas, tools.config['root_path'],title) obj.render() return obj.get()
def _create_table(self, uid, ids, report, fields, tree, results, context): pageSize = common.pageSize.get(report['print_format'], [210.0, 297.0]) if report['print_orientation'] == 'landscape': pageSize = [pageSize[1], pageSize[0]] new_doc = etree.Element('report') config = etree.SubElement(new_doc, 'config') def _append_node(name, text): n = etree.SubElement(config, name) n.text = text _append_node('date', time.strftime('%d/%m/%Y')) _append_node('PageSize', '%.2fmm,%.2fmm' % tuple(pageSize)) _append_node('PageFormat', '%s' % report['print_format']) _append_node('PageWidth', '%.2f' % (pageSize[0] * 2.8346, )) _append_node('PageHeight', '%.2f' % (pageSize[1] * 2.8346, )) length = pageSize[0] - 30 - reduce(lambda x, y: x + (y['width'] or 0), fields, 0) count = 0 for f in fields: if not f['width']: count += 1 for f in fields: if not f['width']: f['width'] = round((float(length) / count) - 0.5) _append_node( 'tableSize', '%s' % ','.join(map(lambda x: '%.2fmm' % (x['width'], ), fields))) _append_node('report-header', '%s' % (report['title'], )) _append_node('report-footer', '%s' % (report['footer'], )) header = etree.SubElement(new_doc, 'header') for f in fields: field = etree.SubElement(header, 'field') field.text = f['name'] lines = etree.SubElement(new_doc, 'lines') for line in results: node_line = etree.SubElement(lines, 'row') for f in range(len(fields)): col = etree.SubElement(node_line, 'col', tree='no') if line[f] != None: col.text = line[f] or '' else: col.text = '/' transform = etree.XSLT( etree.parse( os.path.join(tools.config['root_path'], 'addons/base/report/custom_new.xsl'))) rml = etree.tostring(transform(new_doc)) self.obj = render.rml(rml) self.obj.render() return True
def create_pdf(self, rml, localcontext=None, logo=None, title=None): if logo: self.bin_datas['logo'] = logo else: if 'logo' in self.bin_datas: del self.bin_datas['logo'] obj = render.rml(rml, localcontext, self.bin_datas, tools.config['root_path'], title) obj.render() return obj.get()
def _create_table(self, uid, ids, report, fields, tree, results, context): pageSize = common.pageSize.get(report["print_format"], [210.0, 297.0]) if report["print_orientation"] == "landscape": pageSize = [pageSize[1], pageSize[0]] new_doc = etree.Element("report") config = etree.SubElement(new_doc, "config") def _append_node(name, text): n = etree.SubElement(config, name) n.text = text _append_node("date", time.strftime("%d/%m/%Y")) _append_node("PageSize", "%.2fmm,%.2fmm" % tuple(pageSize)) _append_node("PageFormat", "%s" % report["print_format"]) _append_node("PageWidth", "%.2f" % (pageSize[0] * 2.8346,)) _append_node("PageHeight", "%.2f" % (pageSize[1] * 2.8346,)) length = pageSize[0] - 30 - reduce(lambda x, y: x + (y["width"] or 0), fields, 0) count = 0 for f in fields: if not f["width"]: count += 1 for f in fields: if not f["width"]: f["width"] = round((float(length) / count) - 0.5) _append_node("tableSize", "%s" % ",".join(map(lambda x: "%.2fmm" % (x["width"],), fields))) _append_node("report-header", "%s" % (report["title"],)) _append_node("report-footer", "%s" % (report["footer"],)) header = etree.SubElement(new_doc, "header") for f in fields: field = etree.SubElement(header, "field") field.text = f["name"] lines = etree.SubElement(new_doc, "lines") for line in results: node_line = etree.SubElement(lines, "row") for f in range(len(fields)): col = etree.SubElement(node_line, "col", tree="no") if line[f] is not None: col.text = line[f] or "" else: col.text = "/" transform = etree.XSLT( etree.parse(os.path.join(tools.config["root_path"], "addons/base/report/custom_new.xsl")) ) rml = etree.tostring(transform(new_doc)) self.obj = render.rml(rml) self.obj.render() return True
def create_pdf(self, rml, localcontext = None, logo=None, title=None): if not localcontext: localcontext = {} localcontext.update({'internal_header':self.internal_header}) if logo: self.bin_datas['logo'] = logo else: if 'logo' in self.bin_datas: del self.bin_datas['logo'] obj = render.rml(rml, localcontext, self.bin_datas, self._get_path(), title) obj.render() return obj.get()
def _create_table(self, uid, ids, report, fields, tree, results, context): pageSize=common.pageSize.get(report['print_format'], [210.0,297.0]) if report['print_orientation']=='landscape': pageSize=[pageSize[1],pageSize[0]] new_doc = etree.Element('report') config = etree.SubElement(new_doc, 'config') def _append_node(name, text): n = etree.SubElement(config, name) n.text = text _append_node('date', time.strftime('%d/%m/%Y')) _append_node('PageSize', '%.2fmm,%.2fmm' % tuple(pageSize)) _append_node('PageFormat', '%s' % report['print_format']) _append_node('PageWidth', '%.2f' % (pageSize[0] * 2.8346,)) _append_node('PageHeight', '%.2f' %(pageSize[1] * 2.8346,)) length = pageSize[0]-30-reduce(lambda x,y:x+(y['width'] or 0), fields, 0) count = 0 for f in fields: if not f['width']: count+=1 for f in fields: if not f['width']: f['width']=round((float(length)/count)-0.5) _append_node('tableSize', '%s' % ','.join(map(lambda x: '%.2fmm' % (x['width'],), fields))) _append_node('report-header', '%s' % (report['title'],)) _append_node('report-footer', '%s' % (report['footer'],)) header = etree.SubElement(new_doc, 'header') for f in fields: field = etree.SubElement(header, 'field') field.text = f['name'] lines = etree.SubElement(new_doc, 'lines') for line in results: node_line = etree.SubElement(lines, 'row') for f in range(len(fields)): col = etree.SubElement(node_line, 'col', tree='no') if line[f] is not None: col.text = line[f] or '' else: col.text = '/' transform = etree.XSLT( etree.parse(os.path.join(tools.config['root_path'], 'addons/base/report/custom_new.xsl'))) rml = etree.tostring(transform(new_doc)) self.obj = render.rml(rml) self.obj.render() return True
def create_pdf(self, rml, localcontext = None, logo=None, title=None): if not localcontext: localcontext={} localcontext.update({'internal_header':self.internal_header}) if logo: self.bin_datas['logo'] = logo else: if 'logo' in self.bin_datas: del self.bin_datas['logo'] obj = render.rml(rml, localcontext, self.bin_datas, self._get_path(), title) obj.render() return obj.get()