Skip to content

[18.0][ADD] storage_file: swap backend wizard#622

Open
simahawk wants to merge 7 commits into
OCA:18.0from
camptocamp:18-swap-backend
Open

[18.0][ADD] storage_file: swap backend wizard#622
simahawk wants to merge 7 commits into
OCA:18.0from
camptocamp:18-swap-backend

Conversation

@simahawk
Copy link
Copy Markdown
Contributor

@simahawk simahawk commented May 28, 2026

Add a "Swap Storage Backend" wizard in storage_file to move one or
more storage.file records between backends. Triggered via an
ir.actions.server bound to storage.file list/form views, so it
works on multi-selection from the Action menu.

The wizard is pre-filled with the current selection's backend as
source and refuses any selection spanning multiple backends. The
destination domain excludes the source.

On apply, storage.file._swap_backend(new_backend):

  • downloads the binary from the old backend,
  • uploads to the new one (recomputing relative_path from the
    destination filename_strategy),
  • updates backend_id and relative_path,
  • schedules deletion of the old physical file via cr.postcommit,
    so the original is removed only if the transaction commits. On
    rollback the source file is preserved.

Records already on the destination are skipped.

The wizard exposes a _resolve_file_ids(active_model, active_ids)
hook so submodules can map their own records to the underlying
storage.file ids. storage_image and storage_media will register
server actions on their models that reuse the base wizard.

An additional module storage_file_swap_backend_queue offers the ability to swap big batches of file via jobs.

@OCA-git-bot OCA-git-bot added series:18.0 mod:storage_media Module storage_media mod:storage_file Module storage_file mod:storage_image Module storage_image mod:storage_file_swap_backend_queue Module storage_file_swap_backend_queue labels May 28, 2026
@simahawk
Copy link
Copy Markdown
Contributor Author

Slightly reworked to support jobs via storage_file_swap_backend_queue

Copy link
Copy Markdown
Contributor

@SilvioC2C SilvioC2C left a comment

Choose a reason for hiding this comment

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

Overall LGTM, a few suggestions

Comment thread storage_file/models/storage_file.py Outdated
Comment thread storage_file/wizards/swap_backend.py Outdated
Comment thread storage_file_swap_backend_queue/models/storage_file.py Outdated
simahawk added 2 commits June 5, 2026 16:23
Add a "Swap Storage Backend" wizard in `storage_file` to move one or
more `storage.file` records between backends. Triggered via an
`ir.actions.server` bound to `storage.file` list/form views, so it
works on multi-selection from the Action menu.

The wizard is pre-filled with the current selection's backend as
source and refuses any selection spanning multiple backends. The
destination domain excludes the source.

On apply, `storage.file._swap_backend(new_backend)`:
* downloads the binary from the old backend,
* uploads to the new one (recomputing `relative_path` from the
  destination `filename_strategy`),
* updates `backend_id` and `relative_path`,
* schedules deletion of the old physical file via `cr.postcommit`,
  so the original is removed only if the transaction commits. On
  rollback the source file is preserved.

Records already on the destination are skipped.

The wizard exposes a `_resolve_file_ids(active_model, active_ids)`
hook so submodules can map their own records to the underlying
`storage.file` ids. `storage_image` and `storage_media` will register
server actions on their models that reuse the base wizard.
* drop the postcommit part
* make it hookable so that for big batches of files we can rely on queue_job
@simahawk simahawk force-pushed the 18-swap-backend branch 2 times, most recently from 33b2c01 to 554c826 Compare June 5, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved mod:storage_file_swap_backend_queue Module storage_file_swap_backend_queue mod:storage_file Module storage_file mod:storage_image Module storage_image mod:storage_media Module storage_media series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants