diff --git a/addons/account_edi/models/account_edi_format.py b/addons/account_edi/models/account_edi_format.py index 34e003bee22fec8cec80e6b85bb34ab7bf7df6aa..723c86a6d4494ee01bfce79343ca78b9779939ad 100644 --- a/addons/account_edi/models/account_edi_format.py +++ b/addons/account_edi/models/account_edi_format.py @@ -490,13 +490,9 @@ class AccountEdiFormat(models.Model): res = False try: if file_data['type'] == 'xml': - res = edi_format\ - .with_context(default_move_type=invoice.move_type)\ - ._update_invoice_from_xml_tree(file_data['filename'], file_data['xml_tree'], invoice) + res = edi_format._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)\ - ._update_invoice_from_pdf_reader(file_data['filename'], file_data['pdf_reader'], invoice) + res = edi_format._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) diff --git a/addons/account_edi_ubl_cii/models/account_edi_common.py b/addons/account_edi_ubl_cii/models/account_edi_common.py index 3c359212f86312e87d64a32e8633b34c8ae695af..44e8442cc5a56ec687ab0825654c499a6da0826c 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_common.py +++ b/addons/account_edi_ubl_cii/models/account_edi_common.py @@ -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', None) - 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'] diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/common.py b/addons/l10n_account_edi_ubl_cii_tests/tests/common.py index 84bf371c8e46fcc2ab98965c21c7eae4f05e67f9..fcd8da4675ed9cae85b26c658b21207179b35ca0 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/common.py +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/common.py @@ -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