Why your Odoo filestore is forty gigabytes
TechnoVision
Publication date pending · 6 min read
Odoo’s filestore starts as a detail and becomes an operational problem in about the third year. The backup takes an hour. The disk fills on a Friday. And the documents the business actually cares about are in a directory nobody can browse, search or share without going through Odoo.
Meanwhile the same company has SharePoint or Google Drive, already backed up, already searchable, already covered by a retention policy somebody signed off.
Why "just move them" is harder than it sounds
The naive version is a script that uploads every attachment and deletes the local copy. Three things go wrong, and they go wrong in production rather than in testing.
- Not every attachment is a document. Product images, company logos and report renders are attachments too - and some of them back a binary field, so moving one breaks the field it belongs to.
- Upload failures are normal. A permission nobody granted, a rate limit during a bulk import, a file above the API’s single-request size. If the delete does not depend on proof of success, one of those becomes data loss.
- The upload cannot happen where you want to put it.
The third one is the interesting one
An attachment is created inside the transaction of whoever saved the record. The obvious place to upload it is right there, in the create override.
Do that and saving an invoice now depends on SharePoint being fast. A tenant outage stops people working. A slow API turns a two-second save into a twenty-second one, and the first person to notice will describe it as "Odoo is slow today".
Nobody waiting on a save should ever be waiting on Microsoft.
So the create override does one indexed lookup and queues. A scheduled job does the upload. And the queueing itself is wrapped so that even its own failure cannot fail the save - a person saving a record must never see your bookkeeping error.
Deleting the local copy
This is the feature that reclaims the disk, and it is the same feature that could delete somebody’s only copy of a signed contract. It deserves a rule, and the rule is narrow:
Remove on proof, never on absence of error
Folders somebody can navigate
A flat dump of files named contract.pdf is not an improvement on a filestore. A small template - the model, the year, the record - produces something a person can walk through a year later without knowing anything about Odoo.
Sanitise every segment. A record’s display name is user input, and SharePoint refuses characters Odoo permits. The slash matters most: left in, a customer called "Smith / Jones Ltd" silently creates two folders.
Keep the receipt
Record every filing: the file, the record it came from, who attached it, the folder, the link, and whether the local copy was removed. Six months later somebody will ask where a document went, and the difference between a good answer and an afternoon of searching is a table you already have.