Pete
Pete

Reputation: 713

Openerp report and pdf printing in Windows environment

I'm trying to implement a direct to printer function in Openerp v7 for a windows environment. I have a basic script in python using win32api to launch ghostscript gsprint.

import win32api
invoice = "D:\Downloads\Invoices.pdf"
win32api.ShellExecute(0, 'open', 'C:\Program Files\Ghostgum\gsview\gsprint.exe', invoice, '.', 1)

In openerp the following brings the needed parser for a particular report type and then a report comes out.

report_sxw.report_sxw(
    'report.account.invoice',
    'account.invoice',
    'addons/account/report/account_print_invoice.rml',
    parser=account_invoice
)

This is the stage where I don't know what files I should be looking for to plug in the win32api code. Exploring the files when openerp installs , I see pypdf and reportlab, but these are libraries so I don't believe i should be editing in there.

I simply don't know where to be looking.

Upvotes: 0

Views: 526

Answers (1)

CZoellner
CZoellner

Reputation: 14778

if you want to get the pdf for a stock.picking, try the following code:

import openerp.netsvc as netsvc
report_obj = netsvc.LocalService('report.stock.picking.list') # or any other report
(result_pdf, result_format) = report_obj.create(cr, uid, [res_id], {'report_type': 'pdf'}, context)

result_pdf should be the pdf file. for further questions, just ask :-)

this type of code would be used in models like stock.picking and so on as button method code or else

if you want to get your stuff into the web client "printing button" you have to override the web controller for reports. you can find that in web.controllers.main.Reports and some examples on the net to override it (for example to get better file names...)

Upvotes: 1

Related Questions