Skip to content
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

[13.0-14.0] odoo_backup_sh: get Access denied when list_db=False #1113

Open
trojikman opened this issue May 4, 2021 · 5 comments
Open

[13.0-14.0] odoo_backup_sh: get Access denied when list_db=False #1113

trojikman opened this issue May 4, 2021 · 5 comments

Comments

@trojikman
Copy link
Contributor

trojikman commented May 4, 2021

Steps to reproduce:

  1. as mentioned set list_db = False in odoo.conf
  2. insert and uncomment this code d5eeae9
  3. Make a backup manually or wait until it starts by schedule
  4. Get this error:
odoo_1   | 2021-05-04 14:07:46,240 31 INFO backup odoo.addons.base.models.ir_cron: Starting job `Odoo-backup.sh: Backup the "backup" database, send it to odoo_backup_sh storage, apply rotation`. 
odoo_1   | 2021-05-04 14:07:46,263 31 ERROR backup odoo.service.db: Database management functions blocked, admin disabled database listing 
odoo_1   | 2021-05-04 14:07:46,263 31 ERROR backup odoo.addons.base.models.ir_cron: Call from cron Odoo-backup.sh: Backup the "backup" database, send it to odoo_backup_sh storage, apply rotation for server action #139 failed in Job #11 
odoo_1   | Traceback (most recent call last):
odoo_1   |   File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_cron.py", line 110, in _callback
odoo_1   |     self.env['ir.actions.server'].browse(server_action_id).run()
odoo_1   |   File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 534, in run
odoo_1   |     res = func(action, eval_context=eval_context)
odoo_1   |   File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 419, in run_action_code_multi
odoo_1   |     safe_eval(action.sudo().code.strip(), eval_context, mode="exec", nocopy=True)  # nocopy allows to return 'action'
odoo_1   |   File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 354, in safe_eval
odoo_1   |     return unsafe_eval(c, globals_dict, locals_dict)
odoo_1   |   File "", line 1, in <module>
odoo_1   |   File "/mnt/addons/misc-addons/odoo_backup_sh/models/odoo_backup_sh.py", line 695, in make_backup
odoo_1   |     name, service, ts
odoo_1   |   File "/mnt/addons/misc-addons/odoo_backup_sh/models/odoo_backup_sh.py", line 636, in get_dump_stream_and_info_file
odoo_1   |     dump_stream = odoo.service.db.dump_db(name, None, "zip")
odoo_1   |   File "<decorator-gen-9>", line 2, in dump_db
odoo_1   |   File "/usr/lib/python3/dist-packages/odoo/service/db.py", line 39, in if_db_mgt_enabled
odoo_1   |     raise AccessDenied()
odoo_1   | odoo.exceptions.AccessDenied: Access denied

Expected behavior: backup done as expected
Affected versions: it tested only on 13.0, 14.0; after fix needs to check other versions

@yelizariev
Copy link
Collaborator

Related commit in odoo: odoo/odoo@b02dea7

@yelizariev
Copy link
Collaborator

Похоже надо еще код добавить, который пользователь сам должен раскомментировать

В этом месте:

dump_stream = odoo.service.db.dump_db(name, None, "zip")

Добавить в виде комментария следующей код (я частично протестировал в шеле)

from unittest.mock import patch                                                                                       
with patch.dict(odoo.tools.config.options, {'list_db': True}):
     dump_stream = odoo.service.db.dump_db(name, None, "zip") 

@trojikman
Copy link
Contributor Author

trojikman commented May 10, 2021

Похоже надо еще код добавить, который пользователь сам должен раскомментировать

В этом месте:

dump_stream = odoo.service.db.dump_db(name, None, "zip")

Добавить в виде комментария следующей код (я частично протестировал в шеле)

from unittest.mock import patch                                                                                       
with patch.dict(odoo.tools.config.options, {'list_db': True}):
     dump_stream = odoo.service.db.dump_db(name, None, "zip") 

С этим работает, а вот это судя по всему не актуально. Надо дополнительно в 14 протестировать

@yelizariev
Copy link
Collaborator

Актуально -- ты иначе не сможешь выбрать другие базы

@trojikman trojikman changed the title [13.0] odoo_backup_sh: get Access denied when list_db=False [13.0-14.0] odoo_backup_sh: get Access denied when list_db=False May 10, 2021
@trojikman
Copy link
Contributor Author

trojikman commented May 20, 2021

The issue is fixed in v13 but we need this commit in v14 at least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants