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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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.
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
You should define your splitting criteria for lines and print the sum in the footer.
eg: fix 10 lines in each pdf page
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
Sub-total on the Report
Solved
|
|
2
Mar 18
|
4613 | |
|
0
Apr 24
|
329 | ||
|
1
Aug 23
|
2772 | ||
|
2
Apr 18
|
17878 | ||
|
4
Aug 17
|
20051 |