3

I have been stuck in two days to fix the problem. I would like to get the binary data or content of pdf file and saving it in a variable with or without throwing the pdf file to user. Here are my codes :

def generate_printout(self):

    data = self.read([self.id])[0]        
    datas = {
        'ids': [],
        'model': 'monthly.bill.wizard', # wizard model name
        'form': data,
        'context':self.env.context
    }

    # -------- HOW TO GET THE CONTENT OF PDF FILE -------- 

    return {
        'type': 'ir.actions.report.xml',
        'report_name': 'ig_bill.monthly_bill_printout_report_template',#module name.report template name
        'datas': datas,
    }   

    # -------- HOW TO GET THE CONTENT OF PDF FILE --------

and these are the parser class

class monthly_bill_report(osv.AbstractModel):
    _name = 'report.ig_bill.monthly_bill_printout_report_template'
    _inherit = 'report.abstract_report'
    _template = 'ig_bill.monthly_bill_printout_report_template'
    _wrapped_report_class = monthly_bill_printout_report_parser


class monthly_bill_printout_report_parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context): 
        super(monthly_bill_printout_report_parser, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,            
            'parameter_contact' : self._get_contact,
            etc...
        })
ChesuCR
  • 9,352
  • 5
  • 51
  • 114

1 Answers1

3

You can get it using following method.

report_name = 'external_id_of_your_report'
datas=self.env['report'].get_pdf(self, report_name)

You can get report data using get_pdf method which is available in report module.

In which you need to pass report name.

This may help you.