From 3b172ff276f094a2e598f304f754ca2c01014159 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 7 Dec 2020 10:59:40 +0100 Subject: [PATCH] [FIX] ImportError; --- upgrade_analysis/models/upgrade_analysis.py | 18 ++++++++++++------ .../models/upgrade_comparison_config.py | 10 +++++++++- upgrade_analysis/odoo_patch/addons/__init__.py | 1 - 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/upgrade_analysis/models/upgrade_analysis.py b/upgrade_analysis/models/upgrade_analysis.py index 39320ba0f..8f490e727 100644 --- a/upgrade_analysis/models/upgrade_analysis.py +++ b/upgrade_analysis/models/upgrade_analysis.py @@ -7,8 +7,10 @@ import logging import os from odoo import fields, models +from odoo.exceptions import UserError from odoo.modules import get_module_path from odoo.tools import config +from odoo.tools.translate import _ from .. import compare @@ -35,7 +37,11 @@ class UpgradeAnalysis(models.Model): log = fields.Text(readonly=True) upgrade_path = fields.Char( default=config.get("upgrade_path", False), - help="The base file path to save the analyse files of Odoo modules", + help=( + "The base file path to save the analyse files of Odoo modules. " + "Default is taken from Odoo's --upgrade-path command line option. " + ), + required=True, ) write_files = fields.Boolean( @@ -56,11 +62,6 @@ class UpgradeAnalysis(models.Model): ): module = self.env["ir.module.module"].search([("name", "=", module_name)])[0] if module.is_odoo_module: - if not self.upgrade_path: - return ( - "ERROR: no upgrade_path set when writing analysis of %s\n" - % module_name - ) module_path = os.path.join(self.upgrade_path, module_name) full_path = os.path.join(module_path, version) else: @@ -98,6 +99,11 @@ class UpgradeAnalysis(models.Model): } ) + if not self.upgrade_path: + return ( + "ERROR: no upgrade_path set when writing analysis of %s\n" % module_name + ) + connection = self.config_id.get_connection() RemoteRecord = self._get_remote_model(connection, "record") LocalRecord = self.env["upgrade.record"] diff --git a/upgrade_analysis/models/upgrade_comparison_config.py b/upgrade_analysis/models/upgrade_comparison_config.py index 6bce297ce..90553ccf7 100644 --- a/upgrade_analysis/models/upgrade_comparison_config.py +++ b/upgrade_analysis/models/upgrade_comparison_config.py @@ -2,6 +2,8 @@ # Copyright 2016 Opener B.V. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from urllib.error import URLError + import odoorpc from odoo import api, fields, models @@ -39,7 +41,13 @@ class UpgradeComparisonConfig(models.Model): def get_connection(self): self.ensure_one() - remote = odoorpc.ODOO(self.server, port=self.port) + try: + remote = odoorpc.ODOO(self.server, port=self.port) + except URLError: + raise UserError( + _("Could not connect the Odoo server at %s:%s") + % (self.server, self.port) + ) remote.login(self.database, self.username, self.password) self.version = remote.version return remote diff --git a/upgrade_analysis/odoo_patch/addons/__init__.py b/upgrade_analysis/odoo_patch/addons/__init__.py index 3247dc7b6..5710e7497 100644 --- a/upgrade_analysis/odoo_patch/addons/__init__.py +++ b/upgrade_analysis/odoo_patch/addons/__init__.py @@ -1,3 +1,2 @@ from . import mrp -from . import point_of_sale from . import stock