[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.
pull/62/head
Jairo Llopis 2016-07-25 13:34:46 +02:00
parent 8cc632599d
commit 2bf93a1d49
1 changed files with 6 additions and 2 deletions

View File

@ -20,8 +20,6 @@
# #
############################################################################## ##############################################################################
import xlwt
from xlwt.Style import default_style
import cStringIO import cStringIO
from datetime import datetime from datetime import datetime
from openerp.osv.fields import datetime as datetime_field from openerp.osv.fields import datetime as datetime_field
@ -33,6 +31,12 @@ from openerp import pooler
import logging import logging
_logger = logging.getLogger(__name__) _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): class AttrDict(dict):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):