summaryrefslogtreecommitdiff
path: root/addons/account_edi
diff options
context:
space:
mode:
authorBenjamin Frantzen (bfr) <bfr@odoo.com>2020-12-03 08:05:16 +0000
committerBenjamin Frantzen (bfr) <bfr@odoo.com>2020-12-03 10:05:24 +0000
commitdef8eb4b51a80587f2b4a17da82ceb3abb7f017c (patch)
tree076c76c13971d193fb32c9fcea0523ea42b6b39b /addons/account_edi
parentbe443eabe6198235749b43f6989ea9149c909fcc (diff)
[IMP] account_edi: Better OCR management in tests
When importing an xml in tests, if the import fails, the OCR will try to parse the file, which will cause an user access error. This polutes the logs and makes it hard to debug the code/test. With this commit a helper is added to create and invoice with OCR deactivated to be used to import the file. closes odoo/odoo#62730 Related: odoo/enterprise#15124 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Diffstat (limited to 'addons/account_edi')
-rw-r--r--addons/account_edi/tests/common.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/account_edi/tests/common.py b/addons/account_edi/tests/common.py
index eb01e22da99..0a560c1bb81 100644
--- a/addons/account_edi/tests/common.py
+++ b/addons/account_edi/tests/common.py
@@ -34,6 +34,15 @@ class AccountEdiTestCommon(AccountTestInvoicingCommon):
def edi_cron(self):
self.env['account.edi.document'].sudo().with_context(edi_test_mode=True).search([('state', 'in', ('to_send', 'to_cancel'))])._process_documents_web_services()
+ def _create_empty_vendor_bill(self):
+ invoice = self.env['account.move'].create({
+ 'move_type': 'in_invoice',
+ 'journal_id': self.company_data['default_journal_purchase'].id,
+ })
+ if 'extract_state' in invoice._fields:
+ invoice.extract_state = 'done' # prevent ocr
+ return invoice
+
def update_invoice_from_file(self, module_name, subfolder, filename, invoice):
file_path = get_module_resource(module_name, subfolder, filename)
file = open(file_path, 'rb').read()
@@ -58,7 +67,7 @@ class AccountEdiTestCommon(AccountTestInvoicingCommon):
})
journal_id = self.company_data['default_journal_sale']
- invoice = journal_id.with_context(default_move_type='in_invoice')._create_invoice_from_single_attachment(attachment)
+ journal_id.with_context(default_move_type='in_invoice')._create_invoice_from_single_attachment(attachment)
def assert_generated_file_equal(self, invoice, expected_values, applied_xpath=None):
invoice.action_post()