From a33d9b0dcff035cbe92bdbb953cbaa8ce6c46f91 Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Wed, 15 May 2019 09:04:54 +0200 Subject: [PATCH] [FIX] protect import if module is not present (#818) * [FIX] Protect import for uninstalled module --- account_asset_management_xls/report/__init__.py | 15 +++++++++++++-- account_move_batch_validate/__init__.py | 13 ++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/account_asset_management_xls/report/__init__.py b/account_asset_management_xls/report/__init__.py index 486ad18f4..f82441b0c 100644 --- a/account_asset_management_xls/report/__init__.py +++ b/account_asset_management_xls/report/__init__.py @@ -1,2 +1,13 @@ -# -*- coding: utf-8 -*- -from . import account_asset_report_xls + +# The whole python file is ignored when the dependency is missing +# because it contains an old-style rml_parse report which would +# be loaded anyway +try: + from odoo.addons.report_xlsx_helper.report.abstract_report_xlsx \ + import AbstractReportXlsx +except (ImportError, IOError) as err: + import logging + _logger = logging.getLogger(__name__) + _logger.debug(err) +else: + from . import account_asset_report_xls diff --git a/account_move_batch_validate/__init__.py b/account_move_batch_validate/__init__.py index 85bba0cb6..889833d5c 100644 --- a/account_move_batch_validate/__init__.py +++ b/account_move_batch_validate/__init__.py @@ -1,6 +1,13 @@ # -*- coding: utf-8 -*- # Copyright 2014 Camptocamp SA, 2017 ACSONE # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from . import models -from . import wizard +try: + from odoo.addons.queue_job.job \ + import job, Job +except (ImportError, IOError) as err: + import logging + _logger = logging.getLogger(__name__) + _logger.debug(err) +else: + from . import models + from . import wizard