【发布时间】:2016-02-06 11:17:45
【问题描述】:
我正在开发 Hr_Recruitment 模块。我为 HR->Application 添加了一个二进制图像字段。我正在尝试为外部用户添加功能,以通过网站自己填写工作申请。我添加了姓名、电子邮件、电话,恢复网站中的附件字段以进行工作申请。当他们点击提交时,它在 HR-> 工作申请表中更新。但图像字段在应用程序中没有更新。打开工作申请时它显示类似“不能显示选择的图像”。如何解决这个问题?
控制器/main.py
if post.get('image',False):
image = request.registry['ir.attachment']
name = post.get('image').filename
file = post.get('image')
attach = file.stream
file.show()
f = attach.getvalue()
webbrowser.open(image)
attachment_id = Attachments.create(request.cr, request.uid, {
'name': image,
'res_name': image,
'res_model': 'hr.applicant',
'res_id': applicant_id,
'datas': base64.decodestring(str(res[0])),
'datas_fname': post['image'].filename,
}, request.context)
views/templates.xml
<div t-attf-class="form-group">
<label class="col-md-3 col-sm-4 control-label" for="image">Image</label>
<div class="col-md-7 col-sm-8">
<img id="uploadPreview" style="width: 100px; height: 100px;" />
<input id="uploadImage" name="image" type="file" class="file" multiple="true" data-show-upload="true" data-show-caption="true" data-show-preview="true" onchange="PreviewImage();"/>
</div>
</div>
【问题讨论】:
标签: openerp odoo-8 openerp-8 odoo-9 odoo-website