diff --git a/upgrade_analysis/apriori.py b/upgrade_analysis/apriori.py index 2e5883191..4c06538e2 100644 --- a/upgrade_analysis/apriori.py +++ b/upgrade_analysis/apriori.py @@ -2,9 +2,27 @@ to help the matching process """ -renamed_modules = {} +import logging -merged_modules = {} +_logger = logging.getLogger(__name__) + + +try: + from odoo.addons.openupgrade_scripts.apriori import merged_modules, renamed_modules +except ImportError: + renamed_modules = {} + merged_modules = {} + _logger.warning( + "You are using upgrade_analysis without having" + " openupgrade_scripts module available." + " The analysis process will not work properly," + " if you are generating analysis for the odoo modules" + " in an openupgrade context." + ) + +renamed_modules.update({}) + +merged_modules.update({}) # only used here for upgrade_analysis renamed_models = {} diff --git a/upgrade_analysis/models/upgrade_analysis.py b/upgrade_analysis/models/upgrade_analysis.py index 8f490e727..b0463e9f2 100644 --- a/upgrade_analysis/models/upgrade_analysis.py +++ b/upgrade_analysis/models/upgrade_analysis.py @@ -5,6 +5,7 @@ import logging import os +from pathlib import Path from odoo import fields, models from odoo.exceptions import UserError @@ -17,6 +18,11 @@ from .. import compare _logger = logging.getLogger(__name__) _IGNORE_MODULES = ["openupgrade_records", "upgrade_analysis"] +try: + from odoo.addons.openupgrade_scripts import apriori +except ImportError: + apriori = False + class UpgradeAnalysis(models.Model): _name = "upgrade.analysis" @@ -36,7 +42,7 @@ class UpgradeAnalysis(models.Model): log = fields.Text(readonly=True) upgrade_path = fields.Char( - default=config.get("upgrade_path", False), + default=lambda x: x._default_upgrade_path(), help=( "The base file path to save the analyse files of Odoo modules. " "Default is taken from Odoo's --upgrade-path command line option. " @@ -48,6 +54,17 @@ class UpgradeAnalysis(models.Model): help="Write analysis files to the module directories", default=True ) + def _default_upgrade_path(self): + # Return upgrade_path value, if exists + config_value = config.get("upgrade_path", False) + if config_value: + return config_value + # Otherwise, try to guess, with the openupgrade_scripts path + elif apriori: + apriori_path = Path(os.path.abspath(apriori.__file__)) + return os.path.join(apriori_path.parent, "scripts") + return False + def _get_remote_model(self, connection, model): self.ensure_one() if model == "record": @@ -232,3 +249,4 @@ class UpgradeAnalysis(models.Model): "log": general_log, } ) + return True diff --git a/upgrade_analysis/models/upgrade_comparison_config.py b/upgrade_analysis/models/upgrade_comparison_config.py index 95317bf7e..35fcd5005 100644 --- a/upgrade_analysis/models/upgrade_comparison_config.py +++ b/upgrade_analysis/models/upgrade_comparison_config.py @@ -69,7 +69,8 @@ class UpgradeComparisonConfig(models.Model): "message": _( "You are correctly connected to the server %(server)s" " (version %(version)s) with the user %(user_name)s" - ) % dict( + ) + % dict( server=self.server, version=self.version, user_name=user_info["name"], diff --git a/upgrade_analysis/odoo_patch/addons/__init__.py b/upgrade_analysis/odoo_patch/addons/__init__.py index 5710e7497..3247dc7b6 100644 --- a/upgrade_analysis/odoo_patch/addons/__init__.py +++ b/upgrade_analysis/odoo_patch/addons/__init__.py @@ -1,2 +1,3 @@ from . import mrp +from . import point_of_sale from . import stock diff --git a/upgrade_analysis/odoo_patch/addons/point_of_sale/__init__.py b/upgrade_analysis/odoo_patch/addons/point_of_sale/__init__.py new file mode 100644 index 000000000..a67563f42 --- /dev/null +++ b/upgrade_analysis/odoo_patch/addons/point_of_sale/__init__.py @@ -0,0 +1,12 @@ +from odoo import api +from odoo.addons.point_of_sale.models import pos_config +from ...odoo_patch import OdooPatch + + +class PreInitHookPatch(OdooPatch): + target = pos_config.PosConfig + method_names = ['post_install_pos_localisation'] + + @api.model + def post_install_pos_localisation(cr): + """ Do not configure twice pos_localisation""" diff --git a/upgrade_analysis/readme/USAGE.rst b/upgrade_analysis/readme/USAGE.rst deleted file mode 100644 index e69de29bb..000000000