This question has been flagged
2 Replies
4659 Views

For example sale order has 100 lines and it splits in 6 PDF page, here how to show the total for each page lines ?


Thanks.

Avatar
Discard
Best Answer

You have just to catch PDF before it is sent to the browser. If you are not using attachments modify create_single_pdf() in report_sxw.py under /usr/lib/python2.7/openerp/report/, before return pdf, report_xml.report_type, do pdf = generateMyPDF(s.getvalue(title(report_xml.name), pdf)).if not in create_source_pdf()change the last if statement return s.getvalue(), results[0][1] should be pdf = generateMyPDF(report_xml.name, s.getvalue()) return pdf, results[0][1]

If you are using rml reports:

import StringIO
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from pyPdf import PdfFileReader, PdfFileWriter


def generateMyPDF(titles, pdf)
    if title in titles:#title is used here to check if this is the right document to modify (by default title is the string argument in your report action)
        input = PdfFileReader(cStringIO.StringIO(pdf))
        #calculate your subtotals
        #parse pages to calculate subtotals, you can use regex to calculate subtotal,because it depend on your modified invoice.

        for index in range(len(subtotals)):
            packet = StringIO.StringIO()
            can = canvas.Canvas(packet, pagesize=letter)

            #draw your subtotal

            can.save()
            packet.seek(index)
            new_pdf = PdfFileReader(packet)
            page = input.getPage(index)
            page.mergePage(new_pdf.getPage(0))
            output.addPage(page)

    output.write(s)
    return s.getvalue() or pdf, , report_xml.report_type
Avatar
Discard
Best Answer

You should define your splitting criteria for lines and print the sum in the footer.

eg: fix 10 lines in each pdf page

Avatar
Discard