[IMP] import apriori file of openupgrade_scripts, if available

[IMP] guess upgrade_path, if config is not set, and openupgrade_scripts is available
pull/2417/head
Sylvain LE GAL 2020-12-07 12:42:45 +01:00 committed by Stefan Rijnhart
parent 74159600bc
commit 389a348a94
6 changed files with 54 additions and 4 deletions

View File

@ -2,9 +2,27 @@
to help the matching process
"""
renamed_modules = {}
import logging
_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 = {}

View File

@ -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

View File

@ -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"],

View File

@ -1,2 +1,3 @@
from . import mrp
from . import point_of_sale
from . import stock

View File

@ -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"""