Skip to content
Snippets Groups Projects
Commit 7b18c2e7 authored by Ricardo Gomes Rodrigues (rigr)'s avatar Ricardo Gomes Rodrigues (rigr)
Browse files

[FIX] account_edi{,ubl_cii}: disable move_type check


Currently, if the user uploads a facturx document whose move_type does not match the move_type chosen by the user, the document is not auto filled with the information contained in the facturx XML because of a restrictive check. Therefore, the document is empty and is sent to the OCR which acts as a backup.

Starting from this commit, we will remove this restrictive check. So, if the user uploads a facturx document, we will use the move_type define by facturx regardless of the move_type chosen by the user. This means that when we upload a facturx document, we will always use all the information that is in the xml to create the document and avoid using the OCR.

task-id 2961932

closes odoo/odoo#105447

X-original-commit: 81a68544
Signed-off-by: default avatarLaurent Smet <las@odoo.com>
Signed-off-by: default avatarRicardo Gomes Rodrigues (rigr) <rigr@odoo.com>
parent b89dbb2e
No related branches found
No related tags found
No related merge requests found
......@@ -486,9 +486,9 @@ class AccountEdiFormat(models.Model):
res = False
try:
if file_data['type'] == 'xml':
res = edi_format.with_context(default_move_type=invoice.move_type).with_company(invoice.company_id)._update_invoice_from_xml_tree(file_data['filename'], file_data['xml_tree'], invoice)
res = edi_format.with_company(invoice.company_id)._update_invoice_from_xml_tree(file_data['filename'], file_data['xml_tree'], invoice)
elif file_data['type'] == 'pdf':
res = edi_format.with_context(default_move_type=invoice.move_type).with_company(invoice.company_id)._update_invoice_from_pdf_reader(file_data['filename'], file_data['pdf_reader'], invoice)
res = edi_format.with_company(invoice.company_id)._update_invoice_from_pdf_reader(file_data['filename'], file_data['pdf_reader'], invoice)
file_data['pdf_reader'].stream.close()
else: # file_data['type'] == 'binary'
res = edi_format._update_invoice_from_binary(file_data['filename'], file_data['content'], file_data['extension'], invoice)
......
......@@ -247,9 +247,16 @@ class AccountEdiCommon(models.AbstractModel):
# -------------------------------------------------------------------------
def _import_invoice(self, journal, filename, tree, existing_invoice=None):
move_types_allowed, qty_factor = self._get_import_document_amount_sign(filename, tree)
move_type = self._context.get('default_move_type')
if not move_type or move_type not in move_types_allowed or (existing_invoice and existing_invoice.move_type != move_type):
move_types, qty_factor = self._get_import_document_amount_sign(filename, tree)
if not move_types:
return
if journal.type == 'purchase':
move_type = move_types[0]
elif journal.type == 'sale':
move_type = move_types[1]
else:
return
if existing_invoice and existing_invoice.move_type != move_type:
return
invoice = existing_invoice or self.env['account.move']
......
......@@ -71,7 +71,7 @@ class TestUBLCommon(AccountEdiTestCommon):
Create an account.move directly from an xml file, asserts the invoice obtained is the same as the expected
invoice.
"""
new_invoice = self.edi_format.with_context(default_move_type=invoice.move_type)._create_invoice_from_xml_tree(
new_invoice = self.edi_format._create_invoice_from_xml_tree(
xml_filename,
xml_etree,
invoice.journal_id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment