[FIX] upgrade_analysis: fix methods related to noupdate data
parent
dc9a87fffd
commit
7de18509c6
|
@ -3,7 +3,7 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
{
|
{
|
||||||
"name": "Upgrade Analysis",
|
"name": "Upgrade Analysis",
|
||||||
"summary": "performs a difference analysis between modules"
|
"summary": "Performs a difference analysis between modules"
|
||||||
" installed on two different Odoo instances",
|
" installed on two different Odoo instances",
|
||||||
"version": "14.0.2.0.1",
|
"version": "14.0.2.0.1",
|
||||||
"category": "Migration",
|
"category": "Migration",
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
"wizards/view_upgrade_install_wizard.xml",
|
"wizards/view_upgrade_install_wizard.xml",
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
|
"depends": ["base"],
|
||||||
"external_dependencies": {
|
"external_dependencies": {
|
||||||
"python": ["dataclasses", "odoorpc", "openupgradelib"],
|
"python": ["dataclasses", "odoorpc", "openupgradelib"],
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright 2011-2015 Therp BV <https://therp.nl>
|
# Copyright 2011-2015 Therp BV <https://therp.nl>
|
||||||
# Copyright 2016-2020 Opener B.V. <https://opener.am>
|
# Copyright 2016-2020 Opener B.V. <https://opener.am>
|
||||||
# Copyright 2019 Eficent <https://eficent.com>
|
# Copyright 2019 ForgeFlow <https://forgeflow.com>
|
||||||
# Copyright 2020 GRAP <https://grap.coop>
|
# Copyright 2020 GRAP <https://grap.coop>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
# flake8: noqa: C901
|
# flake8: noqa: C901
|
||||||
|
@ -19,9 +19,10 @@ from odoo.tools.convert import nodeattr2bool
|
||||||
from odoo.tools.translate import _
|
from odoo.tools.translate import _
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from odoo.addons.openupgrade_scripts.apriori import renamed_modules
|
from odoo.addons.openupgrade_scripts.apriori import merged_modules, renamed_modules
|
||||||
except ImportError:
|
except ImportError:
|
||||||
renamed_modules = {}
|
renamed_modules = {}
|
||||||
|
merged_modules = {}
|
||||||
|
|
||||||
from .. import compare
|
from .. import compare
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ class UpgradeAnalysis(models.Model):
|
||||||
def _get_remote_model(self, connection, model):
|
def _get_remote_model(self, connection, model):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if model == "record":
|
if model == "record":
|
||||||
if float(self.config_id.version) < 14:
|
if float(self.config_id.version) < 14.0:
|
||||||
return connection.env["openupgrade.record"]
|
return connection.env["openupgrade.record"]
|
||||||
else:
|
else:
|
||||||
return connection.env["upgrade.record"]
|
return connection.env["upgrade.record"]
|
||||||
|
@ -407,30 +408,31 @@ class UpgradeAnalysis(models.Model):
|
||||||
target_dict[xml_id] = record
|
target_dict[xml_id] = record
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _parse_files(self, xml_files, module_name):
|
def _parse_paths(self, xml_paths, module_name):
|
||||||
records_update = {}
|
records_update = {}
|
||||||
records_noupdate = {}
|
records_noupdate = {}
|
||||||
parser = etree.XMLParser(
|
parser = etree.XMLParser(
|
||||||
remove_blank_text=True,
|
remove_blank_text=True,
|
||||||
strip_cdata=False,
|
strip_cdata=False,
|
||||||
)
|
)
|
||||||
for xml_file in xml_files:
|
for xml_path in xml_paths:
|
||||||
try:
|
try:
|
||||||
# This is for a final correct pretty print
|
# This is for a final correct pretty print
|
||||||
# Ref.: https://stackoverflow.com/a/7904066
|
# Ref.: https://stackoverflow.com/a/7904066
|
||||||
# Also don't strip CDATA tags as needed for HTML content
|
# Also don't strip CDATA tags as needed for HTML content
|
||||||
root_node = etree.fromstring(xml_file.encode("utf-8"), parser=parser)
|
tree = etree.parse(xml_path, parser=parser)
|
||||||
except etree.XMLSyntaxError:
|
except etree.XMLSyntaxError:
|
||||||
continue
|
continue
|
||||||
# Support xml files with root Element either odoo or openerp
|
# Support xml files with root Element either odoo or openerp
|
||||||
# Condition: each xml file should have only one root element
|
# Condition: each xml file should have only one root element
|
||||||
# {<odoo>, <openerp> or —rarely— <data>};
|
# {<odoo>, <openerp> or —rarely— <data>};
|
||||||
|
root_node = tree.getroot()
|
||||||
root_node_noupdate = nodeattr2bool(root_node, "noupdate", False)
|
root_node_noupdate = nodeattr2bool(root_node, "noupdate", False)
|
||||||
if root_node.tag not in ("openerp", "odoo", "data"):
|
if root_node.tag not in ("openerp", "odoo", "data"):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_(
|
_(
|
||||||
"Unexpected root Element: %s in file: %s"
|
"Unexpected root Element: %s in file: %s"
|
||||||
% (root_node.getroot(), xml_file)
|
% (tree.getroot(), xml_path)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for node in root_node:
|
for node in root_node:
|
||||||
|
@ -460,15 +462,17 @@ class UpgradeAnalysis(models.Model):
|
||||||
local_record_obj = self.env["upgrade.record"]
|
local_record_obj = self.env["upgrade.record"]
|
||||||
local_modules = local_record_obj.list_modules()
|
local_modules = local_record_obj.list_modules()
|
||||||
for remote_module in remote_record_obj.list_modules():
|
for remote_module in remote_record_obj.list_modules():
|
||||||
local_module = renamed_modules.get(remote_module, remote_module)
|
local_module = renamed_modules.get(
|
||||||
|
remote_module, merged_modules.get(remote_module, remote_module)
|
||||||
|
)
|
||||||
if local_module not in local_modules:
|
if local_module not in local_modules:
|
||||||
continue
|
continue
|
||||||
remote_files = remote_record_obj.get_xml_records(remote_module)
|
remote_paths = remote_record_obj.get_xml_records(remote_module)
|
||||||
local_files = local_record_obj.get_xml_records(local_module)
|
local_paths = local_record_obj.get_xml_records(local_module)
|
||||||
remote_update, remote_noupdate = self._parse_files(
|
remote_update, remote_noupdate = self._parse_paths(
|
||||||
remote_files, remote_module
|
remote_paths, remote_module
|
||||||
)
|
)
|
||||||
local_update, local_noupdate = self._parse_files(local_files, local_module)
|
local_update, local_noupdate = self._parse_paths(local_paths, local_module)
|
||||||
diff = self._get_xml_diff(
|
diff = self._get_xml_diff(
|
||||||
remote_update, remote_noupdate, local_update, local_noupdate
|
remote_update, remote_noupdate, local_update, local_noupdate
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright 2011-2015 Therp BV <https://therp.nl>
|
# Copyright 2011-2015 Therp BV <https://therp.nl>
|
||||||
# Copyright 2016-2020 Opener B.V. <https://opener.am>
|
# Copyright 2016-2020 Opener B.V. <https://opener.am>
|
||||||
# Copyright 2019 Eficent <https://eficent.com>
|
# Copyright 2019 ForgeFlow <https://forgeflow.com>
|
||||||
# Copyright 2020 GRAP <https://grap.coop>
|
# Copyright 2020 GRAP <https://grap.coop>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ class UpgradeRecord(models.Model):
|
||||||
# The order of the keys are important.
|
# The order of the keys are important.
|
||||||
# Load files in the same order as in
|
# Load files in the same order as in
|
||||||
# module/loading.py:load_module_graph
|
# module/loading.py:load_module_graph
|
||||||
files = []
|
paths = []
|
||||||
for key in ["init_xml", "update_xml", "data"]:
|
for key in ["init_xml", "update_xml", "data"]:
|
||||||
if not manifest.get(key):
|
if not manifest.get(key):
|
||||||
continue
|
continue
|
||||||
|
@ -167,6 +167,5 @@ class UpgradeRecord(models.Model):
|
||||||
if not xml_file.lower().endswith(".xml"):
|
if not xml_file.lower().endswith(".xml"):
|
||||||
continue
|
continue
|
||||||
parts = xml_file.split("/")
|
parts = xml_file.split("/")
|
||||||
with open(os.path.join(addon_dir, *parts), "r") as xml_handle:
|
paths.append(os.path.join(addon_dir, *parts))
|
||||||
files.append(xml_handle.read())
|
return paths
|
||||||
return files
|
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
* Pedro M. Baeza <pedro.baeza@gmail.com>
|
* Pedro M. Baeza <pedro.baeza@gmail.com>
|
||||||
* Ferdinand Gassauer <gass@cc-l-12.chircar.at>
|
* Ferdinand Gassauer <gass@cc-l-12.chircar.at>
|
||||||
* Florent Xicluna <florent.xicluna@gmail.com>
|
* Florent Xicluna <florent.xicluna@gmail.com>
|
||||||
* Miquel Raïch <miquel.raich@eficent.com>
|
* Miquel Raïch <miquel.raich@forgeflow.com>
|
||||||
* Sylvain LE GAL <https://twitter.com/legalsylvain>
|
* Sylvain LE GAL <https://twitter.com/legalsylvain>
|
||||||
|
|
|
@ -416,7 +416,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
<li>Pedro M. Baeza <<a class="reference external" href="mailto:pedro.baeza@gmail.com">pedro.baeza@gmail.com</a>></li>
|
<li>Pedro M. Baeza <<a class="reference external" href="mailto:pedro.baeza@gmail.com">pedro.baeza@gmail.com</a>></li>
|
||||||
<li>Ferdinand Gassauer <<a class="reference external" href="mailto:gass@cc-l-12.chircar.at">gass@cc-l-12.chircar.at</a>></li>
|
<li>Ferdinand Gassauer <<a class="reference external" href="mailto:gass@cc-l-12.chircar.at">gass@cc-l-12.chircar.at</a>></li>
|
||||||
<li>Florent Xicluna <<a class="reference external" href="mailto:florent.xicluna@gmail.com">florent.xicluna@gmail.com</a>></li>
|
<li>Florent Xicluna <<a class="reference external" href="mailto:florent.xicluna@gmail.com">florent.xicluna@gmail.com</a>></li>
|
||||||
<li>Miquel Raïch <<a class="reference external" href="mailto:miquel.raich@eficent.com">miquel.raich@eficent.com</a>></li>
|
<li>Miquel Raïch <<a class="reference external" href="mailto:miquel.raich@forgeflow.com">miquel.raich@forgeflow.com</a>></li>
|
||||||
<li>Sylvain LE GAL <<a class="reference external" href="https://twitter.com/legalsylvain">https://twitter.com/legalsylvain</a>></li>
|
<li>Sylvain LE GAL <<a class="reference external" href="https://twitter.com/legalsylvain">https://twitter.com/legalsylvain</a>></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue