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
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
Sub-total on the Report
Đã xử lý
|
|
2
thg 3 18
|
5462 | |
|
0
thg 4 24
|
1757 | ||
|
1
thg 8 23
|
5396 | ||
|
2
thg 4 18
|
19335 | ||
|
4
thg 8 17
|
21568 |