[MIG] upgrade_analysis from 14.0 to 15.0

pull/2417/head
Sylvain LE GAL 2021-10-21 00:20:36 +02:00 committed by Stefan Rijnhart
parent 767fb01fa1
commit a3336031ed
10 changed files with 18 additions and 45 deletions

View File

@ -5,7 +5,7 @@
"name": "Upgrade Analysis",
"summary": "Performs a difference analysis between modules"
" installed on two different Odoo instances",
"version": "14.0.2.1.1",
"version": "15.0.1.0.1",
"category": "Migration",
"author": "Therp BV, Opener B.V., GRAP, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-tools",

View File

@ -1,27 +0,0 @@
# Copyright 2021 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade
_model_renames = [
("openupgrade.analysis.wizard", "upgrade.analysis"),
("openupgrade.attribute", "upgrade.attribute"),
("openupgrade.comparison.config", "upgrade.comparison.config"),
("openupgrade.record", "upgrade.record"),
("openupgrade.generate.records.wizard", "upgrade.generate.record.wizard"),
("openupgrade.install.all.wizard", "upgrade.install.wizard"),
]
_table_renames = [
("openupgrade_analysis_wizard", "upgrade_analysis"),
("openupgrade_attribute", "upgrade_attribute"),
("openupgrade_comparison_config", "upgrade_comparison_config"),
("openupgrade_record", "upgrade_record"),
("openupgrade_generate_records_wizard", "upgrade_generate_record_wizard"),
("openupgrade_install_all_wizard", "upgrade_install_wizard"),
]
@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_models(env.cr, _model_renames)
openupgrade.rename_tables(env.cr, _table_renames)

View File

@ -429,10 +429,8 @@ class UpgradeAnalysis(models.Model):
root_node_noupdate = nodeattr2bool(root_node, "noupdate", False)
if root_node.tag not in ("openerp", "odoo", "data"):
raise ValidationError(
_(
"Unexpected root Element: %s in file: %s"
% (root_node.getroot(), xml_file)
)
_("Unexpected root Element: %(root)s in file: %(file)s")
% {"root": root_node.getroot(), "file": xml_file}
)
for node in root_node:
if node.tag == "data":

View File

@ -43,11 +43,11 @@ class UpgradeComparisonConfig(models.Model):
self.ensure_one()
try:
remote = odoorpc.ODOO(self.server, port=self.port)
except URLError:
except URLError as exc:
raise UserError(
_("Could not connect the Odoo server at %s:%s")
% (self.server, self.port)
)
_("Could not connect the Odoo server at %(server)s:%(port)s")
% {"server": self.server, "port": self.port}
) from exc
remote.login(self.database, self.username, self.password)
self.version = remote.version
return remote
@ -60,7 +60,7 @@ class UpgradeComparisonConfig(models.Model):
ids = user_model.search([("login", "=", "admin")])
user_info = user_model.read([ids[0]], ["name"])[0]
except Exception as e:
raise UserError(_("Connection failed.\n\nDETAIL: %s") % e)
raise UserError(_("Connection failed.\n\nDETAIL: %s") % e) from e
return {
"type": "ir.actions.client",
"tag": "display_notification",

View File

@ -138,7 +138,7 @@ class UpgradeRecord(models.Model):
@api.model
def list_modules(self):
""" Return the set of covered modules """
"""Return the set of covered modules"""
self.env.cr.execute(
"""SELECT DISTINCT(module) FROM upgrade_record
ORDER BY module"""
@ -152,11 +152,13 @@ class UpgradeRecord(models.Model):
with open(os.path.join(addon_dir, manifest_name), "r") as f:
manifest_string = f.read()
return ast.literal_eval(manifest_string)
raise ValidationError(_("No manifest found in %s" % addon_dir))
raise ValidationError(
_("No manifest found in %(addon_dir)s") % {"addon_dir": addon_dir}
)
@api.model
def get_xml_records(self, module):
""" Return all XML records from the given module """
"""Return all XML records from the given module"""
addon_dir = get_module_path(module)
manifest = self._read_manifest(addon_dir)
# The order of the keys are important.

View File

@ -8,4 +8,4 @@ class PreInitHookPatch(OdooPatch):
method_names = ["_pre_init_mrp"]
def _pre_init_mrp(cr):
""" Don't try to create an existing column on reinstall """
"""Don't try to create an existing column on reinstall"""

View File

@ -10,4 +10,4 @@ class PreInitHookPatch(OdooPatch):
@api.model
def post_install_pos_localisation(cr):
""" Do not configure twice pos_localisation"""
"""Do not configure twice pos_localisation"""

View File

@ -8,4 +8,4 @@ class PreInitHookPatch(OdooPatch):
method_names = ["pre_init_hook"]
def pre_init_hook(cr):
""" Don't unlink stock data on reinstall """
"""Don't unlink stock data on reinstall"""

View File

@ -10,7 +10,7 @@ class BaseModelPatch(OdooPatch):
@api.model
def _convert_records(self, records, log=lambda a: None):
""" Log data ids that are imported with `load` """
"""Log data ids that are imported with `load`"""
current_module = self.env.context["module"]
for res in BaseModelPatch._convert_records._original_method(
self, records, log=log

View File

@ -141,7 +141,7 @@ def log_model(model, local_registry):
}
if v.type == "selection":
if isinstance(v.selection, (tuple, list)):
properties["selection_keys"] = str(sorted([x[0] for x in v.selection]))
properties["selection_keys"] = str(sorted(x[0] for x in v.selection))
else:
properties["selection_keys"] = "function"
elif v.type == "binary":