|
@ -37,13 +37,13 @@ def assemble_pdf(pdf_list): |
|
|
# Even though we are using PyPDF2 we can't use PdfFileMerger |
|
|
# Even though we are using PyPDF2 we can't use PdfFileMerger |
|
|
# as this issue still exists in mostly used wktohtml reports version |
|
|
# as this issue still exists in mostly used wktohtml reports version |
|
|
# http://code.google.com/p/wkhtmltopdf/issues/detail?id=635 |
|
|
# http://code.google.com/p/wkhtmltopdf/issues/detail?id=635 |
|
|
#merger = PdfFileMerger() |
|
|
|
|
|
#merger.append(fileobj=StringIO(invoice_pdf)) |
|
|
|
|
|
#merger.append(fileobj=StringIO(bvr_pdf)) |
|
|
|
|
|
|
|
|
# merger = PdfFileMerger() |
|
|
|
|
|
# merger.append(fileobj=StringIO(invoice_pdf)) |
|
|
|
|
|
# merger.append(fileobj=StringIO(bvr_pdf)) |
|
|
|
|
|
|
|
|
#with tempfile.TemporaryFile() as merged_pdf: |
|
|
|
|
|
#merger.write(merged_pdf) |
|
|
|
|
|
#return merged_pdf.read(), 'pdf' |
|
|
|
|
|
|
|
|
# with tempfile.TemporaryFile() as merged_pdf: |
|
|
|
|
|
# merger.write(merged_pdf) |
|
|
|
|
|
# return merged_pdf.read(), 'pdf' |
|
|
|
|
|
|
|
|
output = PdfFileWriter() |
|
|
output = PdfFileWriter() |
|
|
for pdf in pdf_list: |
|
|
for pdf in pdf_list: |
|
@ -93,7 +93,8 @@ class PDFReportAssembler(report_sxw.report_sxw): |
|
|
|
|
|
|
|
|
report_ids = self._get_report_ids(cr, uid, ids, context=context) |
|
|
report_ids = self._get_report_ids(cr, uid, ids, context=context) |
|
|
|
|
|
|
|
|
pdf_reports = self._generate_all_pdf(cr, uid, ids, data, report_ids, context=context) |
|
|
|
|
|
|
|
|
pdf_reports = self._generate_all_pdf( |
|
|
|
|
|
cr, uid, ids, data, report_ids, context=context) |
|
|
|
|
|
|
|
|
pdf_assemblage = assemble_pdf(pdf_reports) |
|
|
pdf_assemblage = assemble_pdf(pdf_reports) |
|
|
return pdf_assemblage, 'pdf' |
|
|
return pdf_assemblage, 'pdf' |
|
@ -103,8 +104,10 @@ class PDFReportAssembler(report_sxw.report_sxw): |
|
|
Code taken from report openoffice. Thanks guys :) """ |
|
|
Code taken from report openoffice. Thanks guys :) """ |
|
|
pool = pooler.get_pool(cr.dbname) |
|
|
pool = pooler.get_pool(cr.dbname) |
|
|
ir_obj = pool.get('ir.actions.report.xml') |
|
|
ir_obj = pool.get('ir.actions.report.xml') |
|
|
report_xml_ids = ir_obj.search(cr, uid, |
|
|
|
|
|
[('report_name', '=', self.name[7:])], context=context) |
|
|
|
|
|
|
|
|
report_xml_ids = ir_obj.search( |
|
|
|
|
|
cr, uid, |
|
|
|
|
|
[('report_name', '=', self.name[7:])], |
|
|
|
|
|
context=context) |
|
|
if report_xml_ids: |
|
|
if report_xml_ids: |
|
|
|
|
|
|
|
|
report_xml = ir_obj.browse(cr, |
|
|
report_xml = ir_obj.browse(cr, |
|
@ -117,10 +120,13 @@ class PDFReportAssembler(report_sxw.report_sxw): |
|
|
report_xml.report_sxw_content = None |
|
|
report_xml.report_sxw_content = None |
|
|
report_xml.report_sxw = None |
|
|
report_xml.report_sxw = None |
|
|
else: |
|
|
else: |
|
|
return super(PDFReportAssembler, self).create(cr, uid, ids, data, context) |
|
|
|
|
|
|
|
|
return super(PDFReportAssembler, self).create( |
|
|
|
|
|
cr, uid, ids, data, context) |
|
|
if report_xml.report_type != 'assemblage': |
|
|
if report_xml.report_type != 'assemblage': |
|
|
return super(PDFReportAssembler, self).create(cr, uid, ids, data, context) |
|
|
|
|
|
result = self.create_source_pdf(cr, uid, ids, data, report_xml, context) |
|
|
|
|
|
|
|
|
return super(PDFReportAssembler, self).create( |
|
|
|
|
|
cr, uid, ids, data, context) |
|
|
|
|
|
result = self.create_source_pdf( |
|
|
|
|
|
cr, uid, ids, data, report_xml, context) |
|
|
if not result: |
|
|
if not result: |
|
|
return (False, False) |
|
|
return (False, False) |
|
|
return result |
|
|
return result |