Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions fs_attachment_s3_migration/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
=======================
Attachment S3 Migration
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d960aff14147c786815a9ef2f0b78a6d07809a632d627986d30435e07b4c60da
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github
:target: https://github.com/OCA/storage/tree/16.0/fs_attachment_s3_migration
:alt: OCA/storage
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/storage-16-0/storage-16-0-fs_attachment_s3_migration
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/storage&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module lets users move existing ``ir.attachment`` files from the
standard filestore or database into an Amazon S3-backed ``fs.storage``,
using a wizard directly on the storage form.

Migrations are run in background batches, skipping attachments that are
already stored in S3 or must remain in PostgreSQL. This allows to run
the process repeatedly avoiding creating duplicates.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Open the target S3 ``fs.storage`` record and click *Move existing
attachments to S3* in the header.
2. In the migration wizard, keep or adjust the storage code, batch size,
queue channel, and optional *Max Batches* value, then confirm to
enqueue jobs.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/storage/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/storage/issues/new?body=module:%20fs_attachment_s3_migration%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Cetmix

Contributors
------------

Cetmix (cetmix.com)

- Ivan Sokolov
- George Smirnov

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/storage <https://github.com/OCA/storage/tree/16.0/fs_attachment_s3_migration>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions fs_attachment_s3_migration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
21 changes: 21 additions & 0 deletions fs_attachment_s3_migration/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 Cetmix OU
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Attachment S3 Migration",
"summary": """Async migration of attachments from local datastore to S3""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Odoo Community Association (OCA), Cetmix",
"website": "https://github.com/OCA/storage",
"depends": [
"queue_job",
"fs_attachment_s3",
],
"data": [
"security/ir.model.access.csv",
"data/queue_job_channel_data.xml",
"views/fs_storage_view.xml",
"views/migration_wizard_views.xml",
],
"installable": True,
}
19 changes: 19 additions & 0 deletions fs_attachment_s3_migration/data/queue_job_channel_data.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setting is neither documented nor explained, however it's a very important one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll add comment a comment in the XML explaining the channel purpose.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<!--
Queue job channel for S3 migration tasks.

This channel allows controlling concurrency of migration jobs.
Default capacity is inherited from root (1 concurrent job).

To increase parallelism, configure in queue.job.channel settings or
via server environment configuration:

Check https://github.com/OCA/queue/tree/18.0/queue_job documentation for more details.

-->
<record id="queue_channel_s3_migration" model="queue.job.channel">
<field name="name">s3_migration</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>
</odoo>
5 changes: 5 additions & 0 deletions fs_attachment_s3_migration/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2025 Cetmix OU
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import ir_attachment
from . import fs_storage
38 changes: 38 additions & 0 deletions fs_attachment_s3_migration/models/fs_storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2025 Cetmix OU
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, fields, models
from odoo.exceptions import UserError


class FsStorage(models.Model):
_inherit = "fs.storage"

migration_batch_size = fields.Integer(
default=500,
help="Number of attachments per background job batch.",
)

migration_channel = fields.Char(
string="Queue Channel",
default="root.s3_migration",
help="queue_job channel to use for migration jobs.",
)

def action_open_migration_wizard(self):
"""Open the S3 migration wizard for this storage."""
self.ensure_one()
if not self.code:
raise UserError(_("Storage must have a code to run migration."))
return {
"type": "ir.actions.act_window",
"res_model": "s3.migration.wizard",
"view_mode": "form",
"target": "new",
"context": {
"default_storage_id": self.id,
"default_storage_code": self.code,
"default_batch_size": self.migration_batch_size,
"default_channel": self.migration_channel,
},
}
Loading