Skip to Content
Menu
This question has been flagged
1 Reply
7202 Views

Hello

I'm using odoo version 11

I am writing a module which makes a panel for designers who are going to sell their designs.

while submitting a form, and adding a new design to the related model, it's fine by the admin user, but for other users i get the following error:

 Access Denied by ACLs for operation: create, uid: 8, model: design.file

and design.file is my model name

and then it says:

Sorry, you are not allowed to create this kind of document. Please contact your system administrator if you think this is an error.\n\n(Document model: design.file) - (Operation: create, User: 8)', None)

here is my controller code:

@http.route('/someurl', type='http', auth="user", methods=['POST'], website=False)
def upload_handle(self, **post):
post.get('picture')

vals = {
'design_name': post.get('design_name'),
'design_type': post.get('design_type'),
'file_type': post.get('file_type'),
'DPI': post.get('dpi'),
'file_orientation': post.get('file_orientation'),
'width': post.get('width'),
'height': post.get('height'),
# 'image_file': post.get('picture')
}

design_model = http.request.env['design.file']
design_model.create(vals)
return request.render('designer_panel.file_uploaded_successfully', lazy=True)
Avatar
Discard
Best Answer

Hi,

The user who try to create this record does not have create permission in the corresponding model. So to fix this issue, you have to grand the create permission for this user group or you can bypass the security by using the sudo in the code.

Using sudo is not suggested method : - design_model.sudo().create(vals)



To grand the access rights from user interface, navigate to settings -> Technical -> Security -> Access Control List and add a new rule for this model.


To set the access rights from code, see this: How To Set Access Rights For Models in Odoo



Thanks


Avatar
Discard