many2many_binary
Several files on one record, uploaded in one go: the many2many_binary widget turns a many2many to ir.attachment into Odoo's multi file upload zone.
| Technical name | many2many_binary |
|---|---|
| Field types | many2many |
| Views | form |
| Module | web, present in every Odoo database |
| Used in core | 13 occurrences across 10 modules, including mail, hr_recruitment, pos_self_order, mail_group, survey, hr_holidays |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0 |
| No-code setup | No. Studio's Many2Many widgets are Checkboxes and Tags; this widget plus its ir.attachment relation are set up in XML. |
| Alternatives | binary, image, one2many, many2many_tags |
What the Attachments field does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
accepted_file_extensions | string | Comma separated extension list passed to the file picker's accept filter, like '.pdf,.docx'. A picker convenience only; nothing re-validates what users force through with All Files. |
number_of_files | integer | Hides the attach button once the number of linked files reaches this value. Existing extras remain untouched, and API writes ignore the cap. Unset means unlimited. |
number_of_files is a soft cap. The template hides the attach button once the linked count reaches the limit; it never deletes or blocks existing records above it, and records arriving through code or imports bypass it entirely. Treat it as UI guidance, and enforce hard limits server side when they matter.
Working examples
The attachment pipeline behind the cards
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. No functional change visible on the development branch. Details below. |
| Odoo 19.0 | Verified | Verified against the shipped source. Image attachments gain inline thumbnails. |
| Odoo 18.0 | Verified | Same options and upload flow. No image detection, so all files rendered with mimetype icons. |
Upgrade note for 18 to 19. Views carry over untouched. The visible gain is image thumbnails: 18's component had no image detection, so every file rendered with the generic mimetype icon, while 19 previews image attachments inline. Options are identical across the two versions.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| Uploads fail or nothing links to the record | The many2many does not target ir.attachment, so the upload controller's records cannot be linked. Point the field at ir.attachment; wrap attachments in a child model only when you need extra columns. |
| The attach button disappeared | number_of_files was reached, or the field is readonly on this record. Raise or drop the cap, or check the readonly modifier. |
| Upload button carries a strange caption | The caption is the field's label string. Rename the field label to what the button should say. |
| A file was deleted with one click and no warning | The delete cross unlinks immediately; the widget has no confirmation dialog. Expected. Restrict deletion rights or handle retention server side for sensitive documents. |
| No image previews, only generic icons | On 18 that is the only rendering; on 19 the attachment's mimetype is not image/ prefixed, often from files uploaded with a wrong type. Upgrade, or fix the stored mimetype on the attachment. |
| Widget errors on a one2many field | supportedTypes is many2many only. Use a many2many to ir.attachment, or an embedded one2many list on a wrapper model. |
Attachments field vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
many2many_binary | Several loose files accumulated on one record | Multi upload into real ir.attachment records |
| binary | Exactly one file with a fixed meaning | Single column storage, no attachment records |
| image | One picture displayed on the record | Inline image rendering with resized variants |
| one2many | Files needing per file metadata columns | Embedded list on a wrapper model, columns included |
| many2many_tags | Linking existing records rather than uploading | Pill selection UI, no upload path |
Frequently asked questions
How do I let users upload multiple files on one Odoo record?+
Does many2many_binary require ir.attachment?+
How do I limit how many files can be attached?+
Can I restrict uploads to certain file types?+
Why does the upload button say the field name?+
Do image attachments show previews?+
Is there a Studio way to add this widget?+
Does many2many_binary change in Odoo 20?+
Attachment sprawl creeping into your workflows?
Multi file uploads are easy to add and hard to govern: storage grows, sensitive documents hide in odd corners, and nobody owns cleanup. We implement document handling on Odoo with the access rules, retention and filestore strategy worked out, so attachments stay an asset instead of a liability.
Book a free consultation