Skip to content

Commit

Permalink
[UPD]
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Nov 3, 2020
1 parent f30c1e3 commit 66ce7c5
Show file tree
Hide file tree
Showing 150 changed files with 216 additions and 858 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ repos:
exclude: /README\.rst$|\.pot?$
- id: end-of-file-fixer
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
exclude: /README\.rst$|\.pot?$|^openupgrade_scripts/script.*.txt
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
Expand Down
1 change: 1 addition & 0 deletions openupgrade_framework/odoo_patch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import odoo
from . import addons

2 changes: 1 addition & 1 deletion openupgrade_framework/odoo_patch/odoo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import modules
from . import tools
from . import service
from . import tools

# Nothing todo the function, the function check_security didn't changed
from . import http
Expand Down
4 changes: 2 additions & 2 deletions openupgrade_framework/odoo_patch/odoo/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from odoo.http import SessionExpiredException, request, OpenERPSession

if True:
def check_security(self):
def _check_security(self):
"""
Check the current authentication parameters to know if those are still
valid. This method should be called at each request. If the
Expand All @@ -29,4 +29,4 @@ def check_security(self):
raise SessionExpiredException("Session expired")


OpenERPSession.check_security = check_security
OpenERPSession.check_security = _check_security
4 changes: 2 additions & 2 deletions openupgrade_framework/odoo_patch/odoo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


if True:
def load(self, fields, data):
def _load(self, fields, data):
"""
Attempts to load the data matrix, and returns a list of ids (or
``False`` if there was an error and no id could be generated) and a
Expand Down Expand Up @@ -176,4 +176,4 @@ def flush(*, xml_id=None, model=None):
'nextrow': nextrow,
}

BaseModel.load = load
BaseModel.load = _load
3 changes: 1 addition & 2 deletions openupgrade_framework/odoo_patch/odoo/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from . import graph

# A lot of changes in the core functions.
# broken. TO BE FIXED.
# from . import loading
from . import loading

# Adapted to V14
from . import migration
Expand Down
8 changes: 4 additions & 4 deletions openupgrade_framework/odoo_patch/odoo/modules/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

if True:

def update_from_db(self, cr):
def _update_from_db(self, cr):
if not len(self):
return
# update the graph with values from the database (if exist)
Expand Down Expand Up @@ -43,7 +43,7 @@ def update_from_db(self, cr):
setattr(package, k, v)


def add_modules(self, cr, module_list, force=None):
def _add_modules(self, cr, module_list, force=None):
if force is None:
force = []
packages = []
Expand Down Expand Up @@ -104,5 +104,5 @@ def add_modules(self, cr, module_list, force=None):
return len(self) - len_graph


Graph.update_from_db = update_from_db
Graph.add_modules = add_modules
Graph.update_from_db = _update_from_db
Graph.add_modules = _add_modules
27 changes: 14 additions & 13 deletions openupgrade_framework/odoo_patch/odoo/modules/loading.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# flake8: noqa
# pylint: skip-file

import itertools
import logging
import sys
import time
Expand All @@ -9,9 +10,9 @@
import odoo.tools as tools
from odoo import api, SUPERUSER_ID
from odoo.modules import loading
from odoo.modules.module import adapt_version, load_openerp_module
from odoo.modules.module import adapt_version, load_openerp_module, initialize_sys_path

from odoo.modules.loading import load_data, load_demo
from odoo.modules.loading import load_data, load_demo, _check_module_names
from odoo.addons.openupgrade_framework.openupgrade import openupgrade_loading

import os
Expand All @@ -20,7 +21,7 @@
_test_logger = logging.getLogger('odoo.tests')


def load_module_graph(cr, graph, status=None, perform_checks=True,
def _load_module_graph(cr, graph, status=None, perform_checks=True,
skip_modules=None, report=None, models_to_check=None, upg_registry=None):
# <OpenUpgrade:CHANGED-SIGNATURE/>
"""Migrates+Updates or Installs all module nodes from ``graph``
Expand Down Expand Up @@ -274,7 +275,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
return loaded_modules, processed_modules


def load_marked_modules(cr, graph, states, force, progressdict, report,
def _load_marked_modules(cr, graph, states, force, progressdict, report,
loaded_modules, perform_checks, models_to_check=None, upg_registry=None):
# <OpenUpgrade:CHANGED-SIGNATURE/>
"""Loads modules marked with ``states``, adding them to ``graph`` and
Expand All @@ -296,7 +297,7 @@ def load_marked_modules(cr, graph, states, force, progressdict, report,
_logger.debug('Updating graph with %d more modules', len(module_list))
# <OpenUpgrade:CHANGE>
# add upg_registry
loaded, processed = load_module_graph(
loaded, processed = _load_module_graph(
cr, graph, progressdict, report=report, skip_modules=loaded_modules,
perform_checks=perform_checks, models_to_check=models_to_check,
upg_registry=upg_registry,
Expand All @@ -309,7 +310,7 @@ def load_marked_modules(cr, graph, states, force, progressdict, report,
return processed_modules


def load_modules(db, force_demo=False, status=None, update_module=False):
def _load_modules(db, force_demo=False, status=None, update_module=False):
initialize_sys_path()

force = []
Expand Down Expand Up @@ -353,7 +354,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
report = registry._assertion_report
# <OpenUpgrade:CHANGE>
# add upg_registry
loaded_modules, processed_modules = load_module_graph(
loaded_modules, processed_modules = _load_module_graph(
cr, graph, status, perform_checks=update_module,
report=report, models_to_check=models_to_check, upg_registry=upg_registry)

Expand Down Expand Up @@ -424,14 +425,14 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
previously_processed = len(processed_modules)
# <OpenUpgrade:CHANGE>
# add upg_registry
processed_modules += load_marked_modules(cr, graph,
processed_modules += _load_marked_modules(cr, graph,
['installed', 'to upgrade', 'to remove'],
force, status, report, loaded_modules, update_module, models_to_check, upg_registry)
# </OpenUpgrade>
if update_module:
# <OpenUpgrade:CHANGE>
# add upg_registry
processed_modules += load_marked_modules(cr, graph,
processed_modules += _load_marked_modules(cr, graph,
['to install'], force, status, report,
loaded_modules, update_module, models_to_check, upg_registry)
# </OpenUpgrade>
Expand Down Expand Up @@ -549,7 +550,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
# STEP 9: save installed/updated modules for post-install tests
registry.updated_modules += processed_modules


loading.load_module_graph = load_module_graph
loading.load_marked_modules = load_marked_modules
loading.load_modules = load_modules
loading.load_module_graph = _load_module_graph
loading.load_marked_modules = _load_marked_modules
loading.load_modules = _load_modules
odoo.modules.load_modules = _load_modules
4 changes: 2 additions & 2 deletions openupgrade_framework/odoo_patch/odoo/modules/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


if True:
def migrate_module(self, pkg, stage):
def _migrate_module(self, pkg, stage):
assert stage in ('pre', 'post', 'end')
stageformat = {
'pre': '[>%s]',
Expand Down Expand Up @@ -115,4 +115,4 @@ def _get_migration_files(pkg, version, stage):
if mod:
del mod

migration.migrate_module = migrate_module
migration.migrate_module = _migrate_module
4 changes: 2 additions & 2 deletions openupgrade_framework/odoo_patch/odoo/modules/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

if True:

def init(self, db_name):
def _init(self, db_name):
self.models = {} # model name/model instance mapping
self._sql_constraints = set()
self._init = True
Expand Down Expand Up @@ -55,4 +55,4 @@ def init(self, db_name):
with closing(self.cursor()) as cr:
self.has_unaccent = odoo.modules.db.has_unaccent(cr)

registry.init = init
registry.init = _init
4 changes: 2 additions & 2 deletions openupgrade_framework/odoo_patch/odoo/tools/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if True:

def _test_xml_id(self, xml_id):
def __test_xml_id(self, xml_id):
if '.' in xml_id:
module, id = xml_id.split('.', 1)
assert '.' not in id, """The ID reference "%s" must contain
Expand All @@ -20,4 +20,4 @@ def _test_xml_id(self, xml_id):
# OpenUpgrade: log entry of XML imports
openupgrade_log.log_xml_id(self.env.cr, self.module, xml_id)

xml_import._test_xml_id = _test_xml_id
xml_import._test_xml_id = __test_xml_id
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from odoo.tools.view_validation import _validators, _logger


def valid_view(arch, **kwargs):
def _valid_view(arch, **kwargs):
for pred in _validators[arch.tag]:
# <OpenUpgrade:CHANGE>
# Do not raise blocking error, because it's normal to
Expand All @@ -26,4 +26,4 @@ def valid_view(arch, **kwargs):
return True


view_validation.valid_view = valid_view
view_validation.valid_view = _valid_view
3 changes: 2 additions & 1 deletion openupgrade_framework/openupgrade/openupgrade_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from odoo import release
from odoo.modules.module import get_module_path
from odoo.tools import config, safe_eval
from odoo.tools.safe_eval import safe_eval
from odoo.tools.config import config

# A collection of functions used in
# odoo/modules/loading.py
Expand Down
25 changes: 10 additions & 15 deletions openupgrade_framework/openupgrade/openupgrade_log.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# coding: utf-8
# Copyright 2011-2015 Therp BV <https://therp.nl>
# Copyright 2016 Opener B.V. <https://opener.am>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

# flake8: noqa: C901

from openupgradelib.openupgrade_tools import table_exists


Expand Down Expand Up @@ -37,29 +36,25 @@ def log_xml_id(cr, module, xml_id):
:param module: The module that contains the xml_id
:param xml_id: the xml_id, with or without 'module.' prefix
"""
if not table_exists(cr, "openupgrade_record"):
if not table_exists(cr, 'openupgrade_record'):
return
if "." not in xml_id:
xml_id = "{}.{}".format(module, xml_id)
if '.' not in xml_id:
xml_id = '%s.%s' % (module, xml_id)
cr.execute(
"SELECT model FROM ir_model_data " "WHERE module = %s AND name = %s",
xml_id.split("."),
)
"SELECT model FROM ir_model_data "
"WHERE module = %s AND name = %s",
xml_id.split('.'))
record = cr.fetchone()
if not record:
# legalsylvain: disabled, due to pylint error
# do we have to log ?
# print("Cannot find xml_id %s" % xml_id)
print("Cannot find xml_id %s" % xml_id)
return
else:
cr.execute(
"SELECT id FROM openupgrade_record "
"WHERE module=%s AND model=%s AND name=%s AND type=%s",
(module, record[0], xml_id, "xmlid"),
)
(module, record[0], xml_id, 'xmlid'))
if not cr.fetchone():
cr.execute(
"INSERT INTO openupgrade_record "
"(module, model, name, type) values(%s, %s, %s, %s)",
(module, record[0], xml_id, "xmlid"),
)
(module, record[0], xml_id, 'xmlid'))

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---Models in module 'auth_totp'---
new model auth_totp.wizard [transient]
---Fields in module 'auth_totp'---
auth_totp / res.users / totp_secret (char) : NEW
---XML records in module 'auth_totp'---

This file was deleted.

Loading

0 comments on commit 66ce7c5

Please sign in to comment.