[FIX] account_facturx: fix too much restrictive XML bill upload

Issue

    - Install Accounting
    - Upload XML bill (tried with a MX one)

    No decoder was found.

Cause

    The _create_invoice_from_xml method gets decoders from overrides of
    _get_xml_decoders. There is only 2 overrides: Belgium & Italy.

    All others countries are not handled. So, this error blocks
    the user.

Solution

    Log the error instead raising it. (Reproduce V12 behavior)

OPW-2170516

closes odoo/odoo#43503

X-original-commit: 592d2a296e4aa6a0c96bb1e56119965cd066ea0f
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Jason Van Malder
2020-01-17 15:38:11 +00:00
committed by Nicolas Martinelli
parent 7253c33956
commit c6dff46203
@@ -299,7 +299,7 @@ class AccountMove(models.Model):
try:
tree = etree.fromstring(content)
except Exception:
raise UserError(_('The xml file is badly formatted : {}').format(attachment.name))
_logger.exception('The xml file is badly formatted : {}'.format(attachment.name))
for xml_type, check_func, decode_func in decoders:
check_res = check_func(tree, attachment.name)
@@ -313,7 +313,7 @@ class AccountMove(models.Model):
try:
return invoice_ids
except UnboundLocalError:
raise UserError(_('No decoder was found for the xml file: {}. The file is badly formatted, not supported or the decoder is not installed').format(attachment.name))
_logger.exception('No decoder was found for the xml file: {}. The file is badly formatted, not supported or the decoder is not installed'.format(attachment.name))
def _remove_ocr_option(self):
if 'extract_state' in self: