[17.0][FIX] auto_backup: allow scheduled backup when list_db is disabled#3640
Draft
klodr wants to merge 1 commit into
Draft
[17.0][FIX] auto_backup: allow scheduled backup when list_db is disabled#3640klodr wants to merge 1 commit into
klodr wants to merge 1 commit into
Conversation
odoo.service.db.dump_db is guarded by check_db_management_enabled, which raises AccessDenied ("Database management functions blocked, admin disabled database listing") when list_db = False is set in the Odoo configuration. Scheduled backups then failed silently, leaving zero-byte files.
list_db only hides database management from the web interface; a scheduled backup is a trusted server-side operation. Re-enable the flag for the duration of the dump through a context manager that always restores its original value, even on error.
Signed-off-by: klodr <klodr@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When
list_db = Falseis set in the Odoo configuration, scheduledauto_backupjobs fail with:
odoo.service.db.dump_dbis decorated with@check_db_management_enabled, whichraises
AccessDeniedwhenlist_dbis False. The scheduled backup then failssilently and leaves a zero-byte dump file — a silent data-loss risk.
Fix
Wrap the
dump_dbcalls inaction_backup()with a small context manager thattemporarily re-enables
list_dbfor the duration of the dump and alwaysrestores its original value (
try/finally, even on error). Adds a regressiontest (
test_action_backup_local_list_db_disabled).Port of #3639.