Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
2246 Lượt xem

0

In a custom module , I add new field ir_attchment_ids . When connecting wih other user (not admin) , I got this error .

Uh-oh! Looks like you have stumbled upon some top-secret records.

Sorry, user (id=8) doesn't have 'read' access to:
- Attachment (ir.attachment)

If you really, really need access, perhaps you can win over your friendly administrator with a batch of freshly baked cookies.


Here is my code

Python :

class AddAttachment(models.Model):
    _name = "add.attachment"
    
     attachment_ids = fields.Many2many("ir.attachment", string="My Attachment") 

XML :



    
        add.ttachment.form
        add.ttachment
        
            
                
                    
                         
                    
                
            
        
    
    
        add.ttachment.tree
        add.ttachment
        
            
              
            
        
    

    
        Add Attachment
        add.attachment
        tree,form
    

SECURITY

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_add_attachment,add.attachment,model_add_attachment,,1,1,1,1

Any idea please ? Thanks.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

This is a bug I've just found and reported to Odoo (link here)

Until Odoo will fix this, I've just applied a custom fix on my model in the create method like:


@api.model_create_multi
def create(self, vals_list):
    recs = super().create(vals_list)
    for rec in recs:
        rec.attachment_ids.update({
            'res_model': self._name,
            'res_id': rec.id,
        })
        return recs

You can retroactively fix existing records in the same manner through a similar script

Hope it helps ;)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I have the same problem. Non-admin users get a read access error when trying to create a record in Odoo 17.
This is a bug which should be fixed asap.

How did you fix that?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

But this is not working

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_add_attachment,add.attachment,model_add_attachment,,1,1,1,1

I think you should try to add base.group_user here or try to create a admin group for your module and add it to your security

Ảnh đại diện
Huỷ bỏ

this is not working

you can try send your code to me so i can check when i free

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
9502
0
thg 11 24
1072
2
thg 12 23
12679
1
thg 11 22
3031
3
thg 7 22
23024