Odoo 20 · Community & Enterprise
Cloudflare R2 Storage for Odoo
Move Odoo attachments off your server into a private Cloudflare R2 bucket. Users keep opening, previewing and emailing files exactly as before, and your filestore and backups shrink.
Why store attachments in R2?
Attachments are usually the largest part of an Odoo database. Put them where storage is cheap and egress is free.
Smaller server & backups
Uploaded files leave the local filestore, so disks, snapshots and database dumps stay small and fast to restore.
Bucket stays private
Files are fetched server-side with signed requests and streamed by Odoo. No public bucket, no guessable links.
Odoo security, unchanged
Every download goes through the same checks as Odoo's own file route: record rules, portal access, public files and access tokens.
Everything keeps working
Previews, downloads, emails with attachments, reports and exports read the content from R2 transparently.
Migrate and roll back
Move existing files with one action or a batch scheduled job, and bring them back to local storage at any time.
Lightweight
Pure Python standard library (AWS Signature V4). Nothing to pip install, works on Odoo.sh and on-premise.
How it works
A file is attached in Odoo
Chatter, documents, generated PDFs... it is uploaded to R2 and removed from the local filestore.
A user opens the file
Odoo checks that this user may read the attachment and the record it belongs to.
Odoo streams it from R2
A signed server-side request fetches the object. R2 credentials never reach the browser.
Simple configuration
Settings › Cloudflare R2: paste your credentials, test the connection, enable.
Move existing files in bulk
Filter attachments by storage, then use Move to Cloudflare R2 or Restore from Cloudflare R2.
Full traceability
Each attachment shows its R2 object key and the secure Odoo URL used to serve it.
Setup guide: generate your R2 access keys
Everything from an empty Cloudflare account to your first file stored in R2.
Generate the R2 credentials in Cloudflare
About 5 minutes. You need a Cloudflare account with access to R2.
Open R2 in the Cloudflare dashboard
Log in at dash.cloudflare.com and choose R2 Object Storage in the left sidebar.
Create a private bucket
Click Create bucket and fill in:
- Bucket name: lowercase letters, numbers and hyphens, e.g.
acme-odoo-files - Location: Automatic, or a location hint close to your Odoo server
- Default storage class: Standard
Click Create bucket. Do not enable public access or a custom domain: the module never needs them.
Create an API token
Go back to the R2 Object Storage overview page and click Manage API tokens on the right of the page (in some dashboard versions it is inside the API button). Click Create API token (an Account token is recommended, so it keeps working if a user leaves) and set:
- Token name: e.g.
odoo-r2-storage - Permissions: Object Read & Write (read, write, list and delete objects)
- Specify bucket(s): Apply to specific buckets only, then select the bucket from step 2
- TTL: Forever, or an expiry date if your security policy requires one
- Client IP address filtering: optional; if you use it, allow your Odoo server's public IP
Click Create API token.
Copy the credentials (shown only once)
The confirmation page shows several values. Copy these three into a safe place now:
- Access Key ID
- Secret Access Key
- The S3 endpoint under Use jurisdiction-specific endpoints for S3 clients:
https://<ACCOUNT_ID>.r2.cloudflarestorage.com
https://<ACCOUNT_ID>.eu.r2.cloudflarestorage.com. Your Account ID is also shown on the R2 overview page.Connect Odoo
Log in as an administrator.
Open the settings
Go to Settings › Cloudflare R2 and tick Enable R2 Storage. The connection fields appear.
Paste the credentials
Fill in the fields with the values from Part A:
| Odoo field | Value | Example |
|---|---|---|
| Service URL | S3 endpoint from step 4 (without the bucket name) | https://3f9a1c2b7d4e.r2.cloudflarestorage.com |
| Bucket Name | Bucket name from step 2 | acme-odoo-files |
| Access Key ID | Access Key ID from step 4 | a1b2c3d4e5f6... |
| Secret Access Key | Secret Access Key from step 4 | â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢ |
| Object Key Prefix | Optional folder inside the bucket, e.g. one per database | acme-prod |
| Allowed MIME Types | Optional; blank uploads every file type | image/*, application/pdf |
Test and save
Click Test R2 Connection. A green Connection successful message confirms Odoo can reach the bucket. Then click Save.
From now on, every new attachment is stored in R2. To move existing files, use Move to Cloudflare R2 on the attachment list, or activate the scheduled action Cloudflare R2: Move Existing Attachments.
Troubleshooting the connection test
| HTTP 403 Access denied | Token is not Object Read & Write, is scoped to another bucket, has expired, blocks your server IP, or the keys were pasted with extra spaces. |
| HTTP 404 Bucket not found | Bucket name misspelled, or the Service URL belongs to another account or jurisdiction (EU buckets need the .eu. endpoint). |
| Connection error / timeout | The Odoo server cannot reach *.r2.cloudflarestorage.com on port 443: check firewall and outbound proxy rules. |
| Service URL ends with the bucket name | Remove it: enter only https://<ACCOUNT_ID>.r2.cloudflarestorage.com and put the bucket in its own field. |
Features
- Automatic upload of new attachments
- Content still readable from Python (emails, reports, exports)
- Replace and delete synced with R2 after the transaction commits
- Shared objects are kept until no attachment uses them
- Optional MIME-type filter, e.g.
image/*, application/pdf - Configurable key prefix to share a bucket between databases
- Scheduled action to migrate existing files in batches
- One-click connection test
Good to know
- Images stored in fields (product images, avatars, logos) and web assets stay local for speed and public access.
- Files already in R2 stay readable if you switch the feature off.
- Before uninstalling, select the Stored in R2 attachments and run Restore from Cloudflare R2.
- Only administrators can move files between storages.
- Works with any S3-compatible endpoint that supports Signature V4.
Need help?
Questions, installation help or customisation: get in touch and we will get back to you.
Developed by Md. Abdullah Al Mamun
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 608 |
| Technical Name |
odoo_r2_storage |
| License | OPL-1 |
| Website | http://aamsoftvalley.com |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module