nb_attachment
A number and a paperclip: how many receipts are attached to an expense. Fifteen lines of code, and one detail worth knowing about when the number updates.
August 27, 2026Updated September 8, 20265 min read
| Technical name | nb_attachment |
|---|---|
| Field types | integer |
| Views | form, list |
| Module | hr_expense, the Expenses app |
| Used in core | 1 occurrence, the expense form in hr_expense |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0 |
| No-code setup | No. It only works on a field with one specific name |
| Alternatives | statinfo, integer, many2many_binary, badge |
What the attachment counter does
What this means for your team
Working examples
Two lines, two quirks
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Byte-identical to Odoo 19 on the development branch. |
| Odoo 19.0 | Verified | Verified against the shipped source. Unchanged in substance since Odoo 17. |
| Odoo 18.0 | Verified | Identical behavior. |
| Odoo 17.0 | Verified | First version. |
| Odoo 16.0 | Not available | Widget does not exist. |
Upgrade note. Nothing to do. The widget arrived in Odoo 17 and is unchanged in substance through Odoo 19. Databases coming from Odoo 16 gain it with the standard expense views.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| The counter is empty | The field is not named the way the widget expects; it reads a literal property from the record. Use it only on the expense count field, or use a stat button with the stat info widget instead. |
| The count does not update after attaching a receipt | The value is captured when the component is created. Reload the form; the record's field is correct, only the rendered snapshot is stale. |
| Options are ignored | The registration has no extractor. Nothing to configure here. |
| The widget renders on a non-integer field | No supported types are declared, so nothing objects. Point it at the intended integer field. |
| Missing widget error | The expenses module is not installed in that database. Install Expenses, or use a stat button. |
Attachment counter vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
nb_attachment | Showing how many receipts an expense carries, on the expense form | A minimal counter that reads one specific field name literally and captures it once |
| statinfo | A count on any model, inside a stat button | Works on any field name and is used throughout core |
| integer | Showing the number plainly | A labelled input rather than a counter |
| many2many_binary | Listing the attachments themselves | Shows the files rather than how many there are |
| badge | A value shown as a pill | Generic badge styling with no attachment meaning |
Frequently asked questions
Can I use nb_attachment on another field?+
Why does the count not refresh?+
Does it support any options?+
What should I use on another model?+
Which versions have it?+
Expense claims that get approved the first time
Receipt capture, approval rules and the accounting behind them decide whether expenses are a monthly argument or a background process. We implement Odoo Expenses end to end on versions 16 through 19.
Book a free consultation