From dfe9f1749b0c09c83cdbb2272982a019bd4788cb Mon Sep 17 00:00:00 2001 From: wan Date: Wed, 31 Jul 2019 14:55:31 +0000 Subject: [PATCH] [IMP] account_facturx: dont propose ocr if treated by facturx Task 2045187 If an invoice has been extracted from facturx, we don't want to send it to the OCR as it is less reliable closes odoo/odoo#35352 Signed-off-by: Cedric Snauwaert (csn) --- addons/account_facturx/models/account_move.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/addons/account_facturx/models/account_move.py b/addons/account_facturx/models/account_move.py index 10be55f919a..e699febfd69 100644 --- a/addons/account_facturx/models/account_move.py +++ b/addons/account_facturx/models/account_move.py @@ -280,6 +280,7 @@ class AccountMove(models.Model): continue self._import_facturx_invoice(tree) + self._remove_ocr_option() buffer.close() except except_orm as e: raise e @@ -318,15 +319,19 @@ class AccountMove(models.Model): if check_res.get('flag') and not check_res.get('error'): invoice = decode_func(tree) if invoice: - try: - # don't propose to send to ocr - invoice.extract_state = 'done' - except AttributeError: - # account_invoice_exctract not installed - pass + invoice._remove_ocr_option() break try: return invoice 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)) + + def _remove_ocr_option(self): + for record in self: + try: + # don't propose to send to ocr + record.extract_state = 'done' + except AttributeError: + # account_invoice_exctract not installed + pass