[Python] Issue with Access Rules for Attachments / odoo 17

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    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 :

    <?xml version="1.0" encoding="utf-8"?>
    <odoo>
    <record id="add_attachment_form_views" model="ir.ui.view">
    <field name="name">add.ttachment.form</field>
    <field name="model">add.ttachment</field>
    <field name="arch" type="xml">
    <form string="Account">
    <sheet>
    <group>
    <field name="attachment_ids" />
    </group>
    </sheet>
    </form>
    </field>
    </record>
    <record id="add_attachment_tree_views" model="ir.ui.view">
    <field name="name">add.ttachment.tree</field>
    <field name="model">add.ttachment</field>
    <field name="arch" type="xml">
    <tree string="Account">
    <field name="attachment_ids" />
    </tree>
    </field>
    </record>

    <record id="open_add_attachment" model="ir.actions.act_window">
    <field name="name">Add Attachment</field>
    <field name="res_model">add.attachment</field>
    <field name="view_mode">tree,form</field>
    </record>


    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.

    Continue reading...

Compartilhe esta Página