From 2bf93a1d49f7c79062ab7c237ceb794cdbdec983 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 25 Jul 2016 13:34:46 +0200 Subject: [PATCH] [FIX][report_xls] Protect xlwt import. Given `xlwt` could happen to not be installed because it is an optional dependency. See https://github.com/odoo/odoo/issues/12897#issuecomment-234928120. --- report_xls/report_xls.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/report_xls/report_xls.py b/report_xls/report_xls.py index f36f38a8..347cb5e9 100644 --- a/report_xls/report_xls.py +++ b/report_xls/report_xls.py @@ -20,8 +20,6 @@ # ############################################################################## -import xlwt -from xlwt.Style import default_style import cStringIO from datetime import datetime from openerp.osv.fields import datetime as datetime_field @@ -33,6 +31,12 @@ from openerp import pooler import logging _logger = logging.getLogger(__name__) +try: + import xlwt + from xlwt.Style import default_style +except ImportError: + _logger.debug("Cannot import xlwt. This module will not be functional.") + class AttrDict(dict): def __init__(self, *args, **kwargs):