Search code examples
odooodoo-12

Can't add items to Many2many in Odoo 12 EE


I defined a Many2many field for ir.attachemnt. The problem is i can' see the Add an item link to add the records.

*.py

attachment_ids = fields.Many2many('ir.attachment', string='Attachments')

*.xml

<notebook>
          <page string='Attachments'>
            <field name="attachment_ids"/>

          </page>
</notebook>

I also tried this:

<field name="attachment_ids" widget="many2many" />

enter image description here

Any idea?


Solution

  • There is only two thing that make Odoo behave like this.

    1. Your view is in edit mode but I think I'm seeing a place holder comments this means it's not the case

    2. Your user is not allowed to create an ir.attachment which is more likely not the case

    3. Your field is readonly.

    If not one of this cases these is wired but if you didn't understand what happen you can force that link to appear by using embedded tree with create attribute set to true

         <field..... >
                 <tree create='1'>
                 ....