From fc977ce5c409f6daf56599b51f600110766e8ce8 Mon Sep 17 00:00:00 2001 From: Chill Date: Thu, 9 Jan 2025 18:29:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=20#IBF5RZ=20app=5Fauto=5Fbackup?= =?UTF-8?q?=E5=9C=A8wl=E5=AE=9E=E4=BE=8B=E4=B8=AD=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E6=98=AF?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E6=9C=BA=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_auto_backup/__manifest__.py | 8 ++++---- app_auto_backup/models/db_backup.py | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app_auto_backup/__manifest__.py b/app_auto_backup/__manifest__.py index 1027a231..82ae3cf4 100644 --- a/app_auto_backup/__manifest__.py +++ b/app_auto_backup/__manifest__.py @@ -6,7 +6,7 @@ { 'name': "Database auto backup and Download,数据库自动备份", - 'version': '16.24.10.09', + 'version': '16.25.01.09', 'summary': 'Automated and odoo database backups. easy download and manage database file. optimized from auto_backup of oca Yenthe Van Ginneken', @@ -18,14 +18,14 @@ 11. Multi-language Support. Multi-Company Support. 12. Support Odoo 18,17,16,15,14,13,12, Enterprise and Community and odoo.sh Edition. 13. Full Open Source. - The Database Auto-Backup module enables the user to make configurations for the automatic backup of the database. + The Database Auto-Backup module enables the user to make configurations for the automatic backup of the database. Backups can be taken on the local system or on a remote server, through SFTP. You only have to specify the hostname, port, backup location and databasename (all will be pre-filled by default with correct data. If you want to write to an external server with SFTP you will need to provide the IP, username and password for the remote backups. The base of this module is taken from Odoo SA V6.1 (https://www.odoo.com/apps/modules/6.0/auto_backup/) and then upgraded and heavily expanded. This module is made and provided by Yenthe Van Ginneken (Oocademy). - Automatic backup for all such configured databases can then be scheduled as follows: - + Automatic backup for all such configured databases can then be scheduled as follows: + 1) Go to Settings / Technical / Automation / Scheduled actions. 2) Search the action 'Backup scheduler'. 3) Set it active and choose how often you wish to take backups. diff --git a/app_auto_backup/models/db_backup.py b/app_auto_backup/models/db_backup.py index 94223b31..27ed2e4d 100644 --- a/app_auto_backup/models/db_backup.py +++ b/app_auto_backup/models/db_backup.py @@ -4,11 +4,13 @@ import os import datetime import time import shutil +import subprocess import json import tempfile from odoo import models, fields, api, tools, _ from odoo.exceptions import Warning, AccessDenied +from odoo.tools import find_pg_tool, exec_pg_environ import odoo import logging @@ -293,8 +295,10 @@ class DbBackup(models.Model): _logger.info('DUMP DB: %s format %s', db_name, backup_format) - cmd = ['pg_dump', '--no-owner'] - cmd.append(db_name) + # cmd = ['pg_dump', '--no-owner'] + # cmd.append(db_name) + cmd = [find_pg_tool('pg_dump'), '--no-owner', db_name] + env = exec_pg_environ() if backup_format == 'zip': with tempfile.TemporaryDirectory() as dump_dir: @@ -306,7 +310,7 @@ class DbBackup(models.Model): with db.cursor() as cr: json.dump(self._dump_db_manifest(cr), fh, indent=4) cmd.insert(-1, '--file=' + os.path.join(dump_dir, 'dump.sql')) - odoo.tools.exec_pg_command(*cmd) + subprocess.run(cmd, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT, check=True) if stream: odoo.tools.osutil.zip_dir(dump_dir, stream, include_dir=False, fnct_sort=lambda file_name: file_name != 'dump.sql') else: @@ -314,6 +318,14 @@ class DbBackup(models.Model): odoo.tools.osutil.zip_dir(dump_dir, t, include_dir=False, fnct_sort=lambda file_name: file_name != 'dump.sql') t.seek(0) return t + # odoo.tools.exec_pg_command(*cmd) + # if stream: + # odoo.tools.osutil.zip_dir(dump_dir, stream, include_dir=False, fnct_sort=lambda file_name: file_name != 'dump.sql') + # else: + # t=tempfile.TemporaryFile() + # odoo.tools.osutil.zip_dir(dump_dir, t, include_dir=False, fnct_sort=lambda file_name: file_name != 'dump.sql') + # t.seek(0) + # return t else: cmd.insert(-1, '--format=c') stdin, stdout = odoo.tools.exec_pg_command_pipe(*cmd) From c24647c62a271517f824fdb2ed7367f8ce6d62aa Mon Sep 17 00:00:00 2001 From: Chill Date: Tue, 14 Jan 2025 14:39:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?app=5Fsaas=E7=9A=8416=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_saas/__manifest__.py | 2 +- app_saas/models/res_config_settings.py | 2 +- app_saas/views/res_config_settings_views.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app_saas/__manifest__.py b/app_saas/__manifest__.py index 6e8f70b3..b4ebac7f 100644 --- a/app_saas/__manifest__.py +++ b/app_saas/__manifest__.py @@ -26,7 +26,7 @@ { 'name': 'odooapp.cn SaaS Client-Ai Passport.Odoo中文应用商店SaaS云服务客户端', - 'version': '16.0.25.01.06', + 'version': '16.0.25.01.14', 'author': 'odooai.cn', 'category': 'Base', 'website': 'https://www.odooai.cn', diff --git a/app_saas/models/res_config_settings.py b/app_saas/models/res_config_settings.py index e570ada0..90e91254 100644 --- a/app_saas/models/res_config_settings.py +++ b/app_saas/models/res_config_settings.py @@ -10,7 +10,7 @@ _logger = logging.getLogger(__name__) class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' - + module_app_cn_po = fields.Boolean('SaaS Chinese PO', help="Checked to Sync Odoo Chinese from www.odooapp.cn") app_saas_db_token = fields.Char('Cloud DB Token', default=True, config_parameter='app_saas_db_token', help="The odooapp SaaS Token for this Odoo Database. You can reset in https://www.odooapp.cn") diff --git a/app_saas/views/res_config_settings_views.xml b/app_saas/views/res_config_settings_views.xml index 79157b01..00d35edd 100644 --- a/app_saas/views/res_config_settings_views.xml +++ b/app_saas/views/res_config_settings_views.xml @@ -13,7 +13,7 @@