[FIX]create attachment for applicant has done any survey answer
bzr revid: sgo@tinyerp.com-20120106103412-2ob2zza4d4bptes5
This commit is contained in:
parent
f19ad8eaf4
commit
b2bb12cb35
|
@ -22,7 +22,7 @@ import os
|
|||
import datetime
|
||||
from lxml import etree
|
||||
from time import strftime
|
||||
|
||||
import base64
|
||||
import tools
|
||||
import netsvc
|
||||
from osv import osv
|
||||
|
@ -425,6 +425,7 @@ class survey_question_wiz(osv.osv_memory):
|
|||
result['arch'] = etree.tostring(root)
|
||||
result['fields'] = {}
|
||||
result['context'] = context
|
||||
|
||||
return result
|
||||
|
||||
def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None):
|
||||
|
@ -441,6 +442,16 @@ class survey_question_wiz(osv.osv_memory):
|
|||
fp = open(ret_file_name, 'wb+');
|
||||
fp.write(result);
|
||||
fp.close();
|
||||
if context.get('active_model') == 'hr.applicant':
|
||||
result = base64.b64encode(result)
|
||||
file_name = file_name + '.pdf'
|
||||
ir_attachment = self.pool.get('ir.attachment').create(cr, uid,
|
||||
{'name': file_name,
|
||||
'datas': result,
|
||||
'datas_fname': file_name,
|
||||
'res_model': context.get('active_model'),
|
||||
'res_id': context.get('active_ids')[0]},
|
||||
context=context)
|
||||
|
||||
except Exception,e:
|
||||
return (False, str(e))
|
||||
|
|
Loading…
Reference in New Issue