Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD][13.0] Support generating noupdate_changes from upgrade_records in 14.0 #2481

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions odoo/addons/openupgrade_records/models/openupgrade_record.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# coding: utf-8
# Copyright 2011-2015 Therp BV <https://therp.nl>
# Copyright 2016 Opener B.V. <https://opener.am>
# Copyright 2016-2020 Opener B.V. <https://opener.am>
# Copyright 2019 Eficent <https://eficent.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import ast
import os
from odoo import api, fields, models
from odoo.exceptions import ValidationError
from odoo.modules.module import get_module_path, MANIFEST_NAMES


class Attribute(models.Model):
Expand Down Expand Up @@ -111,3 +114,40 @@ def field_dump(self):
dict([(x.name, x.value) for x in record.attribute_ids]))
data.append(repre)
return data

@api.model
def list_modules(self):
""" Return the set of covered modules """
self.env.cr.execute(
"""SELECT DISTINCT(module) FROM openupgrade_record
ORDER BY module""")
return [module for module, in self.env.cr.fetchall()]

@staticmethod
def _read_manifest(addon_dir):
for manifest_name in MANIFEST_NAMES:
if os.access(os.path.join(addon_dir, manifest_name), os.R_OK):
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)
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved

@api.model
def get_xml_records(self, 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.
# Load files in the same order as in
# module/loading.py:load_module_graph
files = []
for key in ['init_xml', 'update_xml', 'data']:
if not manifest.get(key):
continue
for xml_file in manifest[key]:
if not xml_file.lower().endswith('.xml'):
continue
parts = xml_file.split('/')
with open(os.path.join(addon_dir, *parts), 'r') as xml_handle:
files.append(xml_handle.read())
MiquelRForgeFlow marked this conversation as resolved.
Show resolved Hide resolved
StefanRijnhart marked this conversation as resolved.
Show resolved Hide resolved
return files