[MERGE] hr_recruitment: fixed bug 910135: when survey answered directly in system, a pdf report is now attached to the applicant

bzr revid: tde@openerp.com-20120106142414-st7ag0nx4q3ppc0f
This commit is contained in:
Thibault Delavallée
2012-01-06 15:24:14 +01:00
+13
View File
@@ -23,6 +23,7 @@ import datetime
from lxml import etree
from time import strftime
import base64
import tools
import netsvc
from osv import osv
@@ -441,6 +442,18 @@ class survey_question_wiz(osv.osv_memory):
fp = open(ret_file_name, 'wb+');
fp.write(result);
fp.close();
# hr.applicant: if survey answered directly in system: attach report to applicant
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))