From 315bcec932a0d2448bccf24a6324b6b5b50bafcf Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 19 Oct 2016 08:58:57 +0200 Subject: [PATCH] 8.0 Use try/except when importing external libs (#8) [FIX] LINT Use try/except when importing external libs Remove self.ensure_one() that has nothing to do in an api.model method --- .../models/business_document_import.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/base_business_document_import/models/business_document_import.py b/base_business_document_import/models/business_document_import.py index 703d66fb9c..9e42beeb98 100644 --- a/base_business_document_import/models/business_document_import.py +++ b/base_business_document_import/models/business_document_import.py @@ -5,15 +5,18 @@ from openerp import models, api, _ from openerp.tools import float_compare from openerp.exceptions import Warning as UserError -import PyPDF2 from lxml import etree from StringIO import StringIO import mimetypes from urlparse import urlparse import logging - logger = logging.getLogger(__name__) +try: + import PyPDF2 +except ImportError: + logger.debug('Cannot import PyPDF2') + class BusinessDocumentImport(models.AbstractModel): _name = 'business.document.import'