3
変数をget_pdf関数から自動的にfields.binary(email_attachment_file)に保存したいとします。ここでは、以下の変数get_pdf()をfields.binaryに保存する
マイコード:
class example_example(models.Model):
email_attachment_file = fields.Binary('Data (.txt,.pdf)')
email_filename = fields.Char('Filename')
def generate(self,etc..):
report_name = "report_name_template"
datas = {
'ids':[],
'model' : etc,
'form' : etc
'context': context
}
moddelReport = self.pool.get('report')
alpha = modelReport.get_pdf(cr, uid,[],report_name,None,datas,context=context)
#alpha = base64.decodestring(alpha)
#alpha = alpha.decode('unicode_escape').encode('utf-8')
# --------- how to save alpha variable into fields.binary
そして、何かが間違っmodelReport.get_pdf機能がありますか?
データからのリターンは%PDF-1.3である 1 0 OBJ << /キッズ[] /タイプ/ページ /カウント0 >> endobj 2 0 OBJ << /プロデューサー(PythonのPDFライブラリ\ 055 http \ 072 \ 057 \ 05pypybrary \ 056net \ 057pyPdf \ 057)..など..、私は解答を見つけるためにそれを理解することができません –
get_pdfは、 base64.encodestring(data)を使用してバイナリで変換する必要があります。 –