2017-07-19 6 views
3

私はこの問題を解決するために2日間で立ち往生しています。私は、バイナリデータまたはpdfファイルの内容を取得し、pdfファイルをユーザーに投げてもしなくても変数に保存したいと考えています。odooでPDFデータやコンテンツを入手する方法8

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 -------- 

及びこれらのあなたは、次の方法を使用してそれを得ることができ

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... 
     }) 

答えて

3

パーサクラスされています。ここに私のコードです。

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

あなたは レポートモジュールで提供されていますget_pdfメソッドを使用してレポートデータを取得することができます。

レポート名を渡す必要があります。

これは役に立ちます。

+0

ありがとうEmpiro Technologies Pvt。 Ltd –

関連する問題