- Some errors will never get fixed until user intervention, it doesn't make sense to run the CRON when there is such error. + some small improvements and esthetic changes - When we are in a CRON, we need to commit the changes between each call to web-service to avoid loss of data. - Small refactor of edi.document prepare_jobs and process_jobs - Added an arbitrary key to create the batches.
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.addons.account_edi.tests.common import AccountEdiTestCommon
|
|
from unittest.mock import patch
|
|
|
|
|
|
class TestAccountEdi(AccountEdiTestCommon):
|
|
|
|
def test_export_edi(self):
|
|
invoice = self.init_invoice('out_invoice')
|
|
self.assertEqual(len(invoice.edi_document_ids), 0)
|
|
invoice.action_post()
|
|
self.assertEqual(len(invoice.edi_document_ids), 1)
|
|
|
|
def test_prepare_jobs(self):
|
|
|
|
edi_docs = self.env['account.edi.document']
|
|
edi_docs |= self.create_edi_document(self.edi_format, 'to_send')
|
|
edi_docs |= self.create_edi_document(self.edi_format, 'to_send')
|
|
|
|
to_process = edi_docs._prepare_jobs()
|
|
self.assertEqual(len(to_process), 2)
|
|
|
|
with patch('odoo.addons.account_edi.models.account_edi_format.AccountEdiFormat._support_batching', return_value=True):
|
|
to_process = edi_docs._prepare_jobs()
|
|
self.assertEqual(len(to_process), 1)
|
|
|
|
other_edi = self.env['account.edi.format'].sudo().create({
|
|
'name': 'Batchable EDI format 2',
|
|
'code': 'test_batch_edi_2',
|
|
})
|
|
|
|
edi_docs |= self.create_edi_document(other_edi, 'to_send')
|
|
edi_docs |= self.create_edi_document(other_edi, 'to_send')
|
|
|
|
with patch('odoo.addons.account_edi.models.account_edi_format.AccountEdiFormat._support_batching', return_value=True):
|
|
to_process = edi_docs._prepare_jobs()
|
|
self.assertEqual(len(to_process), 2)
|