-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! [REF] module_auto_update: Step 3, backwards compatibility
- Loading branch information
Showing
3 changed files
with
35 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Tecnativa - Jairo Llopis | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
import openupgradelib | ||
|
||
import logging | ||
from psycopg2 import IntegrityError | ||
from openerp.addons.module_auto_update.models.module_deprecated import \ | ||
PARAM_DEPRECATED | ||
|
||
import wdb; wdb.set_trace() # TODO DELETE! | ||
# TODO Remove when deprecated features are removed; see README's known issues | ||
@openupgradelib.migrate(no_version=True, use_env=True) | ||
def migrate(env): | ||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def migrate(cr, version): | ||
"""Autoenable deprecated behavior.""" | ||
# Check if deprecation parameter existed | ||
deprecated = env["ir.config_parameter"].get_param(PARAM_DEPRECATED) | ||
if deprecated is False: | ||
# If not, enable deprecated features now, to avoid breaking behavior | ||
env["ir.config_parameter"].set_param(PARAM_DEPRECATED, "1") | ||
try: | ||
cr.execute( | ||
"INSERT INTO ir_config_parameter (key, value) VALUES (%s, '1')", | ||
(PARAM_DEPRECATED,) | ||
) | ||
_logger.warn("Deprecated features have been autoenabled, see " | ||
"addon's README to know how to upgrade to the new " | ||
"supported autoupdate mechanism.") | ||
except IntegrityError: | ||
_logger.info("Deprecated features setting exists, not autoenabling") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters