Good Day I've alter the website_hr_recruitment module to add some function to download some file. But an Error has occcured when I try to download the file without user access. The error is
{"message": "Odoo Server Error", "code": 200, "data": {"debug": "Traceback (most recent call last):\n File \"/opt/odoo/odoo-server/addons/web/controllers/main.py\", line 70, in wrap\n return f(*args, **kwargs)\n File \"/opt/odoo/odoo-server/addons/web/controllers/main.py\", line 1092, in saveas\n res = Model.read(cr, uid, [int(id)], fields, context)[0]\n File \"/opt/odoo/odoo-server/openerp/api.py\", line 268, in wrapper\n return old_api(self, *args, **kwargs)\n File \"/opt/odoo/odoo-server/openerp/addons/base/ir/ir_attachment.py\", line 318, in read\n self.check(cr, uid, ids, 'read', context=context)\n File \"/opt/odoo/odoo-server/openerp/api.py\", line 268, in wrapper\n return old_api(self, *args, **kwargs)\n File \"/opt/odoo/odoo-server/openerp/addons/base/ir/ir_attachment.py\", line 260, in check\n raise except_orm(_('Access Denied'), _(\"Sorry, you are not allowed to access this document.\"))\nexcept_orm: (u'Access Denied', u'Sorry, you are not allowed to access this document.')\n", "exception_type": "except_osv", "message": "Access Denied\nSorry, you are not allowed to access this document.", "name": "openerp.exceptions.except_orm", "arguments": ["Access Denied", "Sorry, you are not allowed to access this document."]}}
Heres the Model
@http.route('/jobs/apply/<model("hr.job"):job>', type='http', auth="public", website=True)
def jobs_apply(self, job):
error = {}
default = {}
#Added by SDS 19022016
attachment = http.request.env['ir.attachment'].sudo().search([('name', '=', 'Application-Form-rev2.docx')])
#str_url = 'http://localhost:8069'+'/web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id='+str(attachment.id)
str_url = request.httprequest.host_url +'web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id='+str(attachment.id)
if 'website_hr_recruitment_bahia_error' in request.session:
error = request.session.pop('website_hr_recruitment_bahia_error')
default = request.session.pop('website_hr_recruitment_bahia_default')
return request.render("website_hr_recruitment_bahia.apply", {
'job': job,
'error': error,
'default': default,
'url_link': str_url,
})
and heres the Template
<div t-attf-class="form-group #{error.get('first_name') and 'has-error' or ''}">
Click ”<a t-att-href="url_link" >Apply Now</a> ” to download, fill-out and upload below
<label class="col-md-3 col-sm-4 control-label" for="first_name">First Name</label>
<div class="col-md-7 col-sm-8">
<input type="text" t-att-value="default.get('first_name')" class="form-control" name="first_name" required="True"/>
</div>
</div>
I tried to add the sudo access but it has no use can someone help me
Thanks