-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from acsone/silence-env-manage-warning-sbi
Silence Environment.manage warning in Odoo 15
- Loading branch information
Showing
6 changed files
with
60 additions
and
36 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,7 +1,7 @@ | ||
# Copyright 2018 ACSONE SA/NV (<http://acsone.eu>) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from .compat import odoo # noqa | ||
from .compat import odoo_bin # noqa | ||
from .env import OdooEnvironment # noqa | ||
from .env import odoo # noqa | ||
from .env import odoo_bin # noqa | ||
from .env_options import env_options # noqa |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import contextlib | ||
|
||
__all__ = [ | ||
"Environment", | ||
"environment_manage", | ||
"odoo", | ||
"odoo_bin", | ||
"odoo_version_info", | ||
] | ||
|
||
try: | ||
import odoo | ||
from odoo.api import Environment | ||
except ImportError as e: | ||
if hasattr(e, "name") and e.name != "odoo": | ||
raise | ||
# Odoo < 10 | ||
try: | ||
import openerp as odoo | ||
from openerp.api import Environment | ||
except ImportError: | ||
if hasattr(e, "name") and e.name != "openerp": | ||
raise | ||
raise ImportError("No module named odoo nor openerp") | ||
|
||
|
||
try: | ||
from odoo.release import version_info as odoo_version_info | ||
except ImportError: | ||
from openerp.release import version_info as odoo_version_info | ||
|
||
|
||
if odoo_version_info < (10, 0): | ||
odoo_bin = "openerp-server" | ||
else: | ||
odoo_bin = "odoo" | ||
|
||
|
||
if odoo_version_info < (15, 0): | ||
environment_manage = Environment.manage | ||
else: | ||
|
||
@contextlib.contextmanager | ||
def environment_manage(): | ||
# Environment.manage is a no-op in Odoo 15+, but it | ||
# emits a noisy warning so let's avoid it. | ||
yield |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Silenced a noisy warning about Environment.manage() being a no-op in Odoo 15. |
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,12 +1,10 @@ | ||
# noqa | ||
try: | ||
import odoo.release as release | ||
import odoo.tools.parse_version as parse_version | ||
except (AttributeError, ImportError): | ||
import openerp.release as release | ||
import openerp.tools.parse_version as parse_version | ||
|
||
if parse_version(release.version) > parse_version("9.0c"): | ||
import odoo.addons.addon1 # noqa | ||
else: | ||
if release.version_info < (10, 0): | ||
import openerp.addons.addon1 # noqa | ||
else: | ||
import odoo.addons.addon1 # noqa |