|
8 | 8 | from lxml import etree
|
9 | 9 | from StringIO import StringIO
|
10 | 10 | from tempfile import NamedTemporaryFile
|
11 |
| -import PyPDF2 |
12 | 11 | import mimetypes
|
13 | 12 | import logging
|
14 |
| - |
15 | 13 | logger = logging.getLogger(__name__)
|
16 | 14 |
|
| 15 | +try: |
| 16 | + import PyPDF2 |
| 17 | +except ImportError: |
| 18 | + logger.debug('Cannot import PyPDF2') |
| 19 | + |
17 | 20 |
|
18 | 21 | class BaseUbl(models.AbstractModel):
|
19 | 22 | _name = 'base.ubl'
|
@@ -459,10 +462,13 @@ def ubl_parse_party(self, party_node, ns):
|
459 | 462 | 'cac:Contact/cbc:Telephone', namespaces=ns)
|
460 | 463 | fax_xpath = party_node.xpath(
|
461 | 464 | 'cac:Contact/cbc:Telefax', namespaces=ns)
|
| 465 | + website_xpath = party_node.xpath( |
| 466 | + 'cbc:WebsiteURI', namespaces=ns) |
462 | 467 | partner_dict = {
|
463 | 468 | 'vat': vat_xpath and vat_xpath[0].text or False,
|
464 | 469 | 'name': partner_name_xpath[0].text,
|
465 | 470 | 'email': email_xpath and email_xpath[0].text or False,
|
| 471 | + 'website': website_xpath and website_xpath[0].text or False, |
466 | 472 | 'phone': phone_xpath and phone_xpath[0].text or False,
|
467 | 473 | 'fax': fax_xpath and fax_xpath[0].text or False,
|
468 | 474 | }
|
@@ -554,7 +560,7 @@ def get_xml_files_from_pdf(self, pdf_file):
|
554 | 560 | xmlfiles = {} # key = filename, value = PDF obj
|
555 | 561 | for embeddedfile in embeddedfiles[:-1]:
|
556 | 562 | mime_res = mimetypes.guess_type(embeddedfile)
|
557 |
| - if mime_res and mime_res[0] in ['application/xml','text/xml']: |
| 563 | + if mime_res and mime_res[0] in ['application/xml', 'text/xml']: |
558 | 564 | xmlfiles[embeddedfile] = embeddedfiles[i+1]
|
559 | 565 | i += 1
|
560 | 566 | logger.debug('xmlfiles=%s', xmlfiles)
|
|
0 commit comments