-
-
Notifications
You must be signed in to change notification settings - Fork 200
[ADD] fs_attachment_s3_migration: enable S3 migration #534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Aldeigja
wants to merge
2
commits into
OCA:16.0
Choose a base branch
from
cetmix:16.0-t5048-fs_attachment_s3_migration-add-module
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import models | ||
| from . import wizard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
19
fs_attachment_s3_migration/data/queue_job_channel_data.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.