Skip to content

Commit 7e79183

Browse files
alexis-viagbrito
authored andcommitted
Add support for extraction + matching on website
PEP8 fix 8.0 Add support for partner bank matching on invoice update (#6) Add support for partner bank matching on invoice update (before, it was only supported on invoice creation) 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
1 parent 8ab7203 commit 7e79183

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

base_ubl/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ Usage
2424

2525
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
2626
:alt: Try me on Runbot
27-
:target: https://runbot.odoo-community.org/runbot/95/8.0
27+
:target: https://runbot.odoo-community.org/runbot/226/8.0
2828

2929
Bug Tracker
3030
===========
3131

3232
Bugs are tracked on `GitHub Issues
33-
<https://github.com/OCA/account-invoicing/issues>`_. In case of trouble, please
33+
<https://github.com/OCA/edi/issues>`_. In case of trouble, please
3434
check there if your issue has already been reported. If you spotted it first,
3535
help us smashing it by providing a detailed and welcomed feedback.
3636

base_ubl/models/ubl.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
from lxml import etree
99
from StringIO import StringIO
1010
from tempfile import NamedTemporaryFile
11-
import PyPDF2
1211
import mimetypes
1312
import logging
14-
1513
logger = logging.getLogger(__name__)
1614

15+
try:
16+
import PyPDF2
17+
except ImportError:
18+
logger.debug('Cannot import PyPDF2')
19+
1720

1821
class BaseUbl(models.AbstractModel):
1922
_name = 'base.ubl'
@@ -459,10 +462,13 @@ def ubl_parse_party(self, party_node, ns):
459462
'cac:Contact/cbc:Telephone', namespaces=ns)
460463
fax_xpath = party_node.xpath(
461464
'cac:Contact/cbc:Telefax', namespaces=ns)
465+
website_xpath = party_node.xpath(
466+
'cbc:WebsiteURI', namespaces=ns)
462467
partner_dict = {
463468
'vat': vat_xpath and vat_xpath[0].text or False,
464469
'name': partner_name_xpath[0].text,
465470
'email': email_xpath and email_xpath[0].text or False,
471+
'website': website_xpath and website_xpath[0].text or False,
466472
'phone': phone_xpath and phone_xpath[0].text or False,
467473
'fax': fax_xpath and fax_xpath[0].text or False,
468474
}
@@ -554,7 +560,7 @@ def get_xml_files_from_pdf(self, pdf_file):
554560
xmlfiles = {} # key = filename, value = PDF obj
555561
for embeddedfile in embeddedfiles[:-1]:
556562
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']:
558564
xmlfiles[embeddedfile] = embeddedfiles[i+1]
559565
i += 1
560566
logger.debug('xmlfiles=%s', xmlfiles)

0 commit comments

Comments
 (0)