[IMP] import apriori file of openupgrade_scripts, if available
[IMP] guess upgrade_path, if config is not set, and openupgrade_scripts is availablepull/2417/head
parent
74159600bc
commit
389a348a94
|
@ -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 = {}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
from . import mrp
|
||||
from . import point_of_sale
|
||||
from . import stock
|
||||
|
|
|
@ -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"""
|
Loading…
Reference in New Issue