Skip to content

Commit db8a752

Browse files
monen17Borruso
authored andcommitted
[FIX] l10n_it_edi_extension: No exception if wrong company
1 parent 1556c49 commit db8a752

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

l10n_it_edi_extension/models/account_move.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,11 @@ def _l10n_it_edi_import_invoice(self, invoice, data, is_new):
10411041
)
10421042
self._l10n_it_edi_extension_update_partner_bank(body_tree, invoice)
10431043

1044-
if tax_representative := self._l10n_it_edi_extension_create_partner(
1045-
body_tree,
1046-
"tax_representative",
1044+
if invoice and (
1045+
tax_representative := self._l10n_it_edi_extension_create_partner(
1046+
body_tree,
1047+
"tax_representative",
1048+
)
10471049
):
10481050
invoice.l10n_it_edi_tax_representative_id = tax_representative
10491051

l10n_it_edi_extension/tests/test_import_edi_extension_xml.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,24 @@ def test_partner_default_product_tax_detail_level(self):
510510
},
511511
],
512512
)
513+
514+
def test_import_wrong_company(self):
515+
"""If the invoice is not of current company,
516+
there is no exception during parsing"""
517+
# Arrange
518+
company = self.company
519+
company.l10n_it_codice_fiscale = False
520+
521+
# Act
522+
invoice = self._assert_import_invoice(
523+
"IT02780790107_11004.xml",
524+
[
525+
{},
526+
],
527+
)
528+
529+
# Assert
530+
error_message = invoice.message_ids.filtered(
531+
lambda message: "Error importing attachment" in (message.body or "")
532+
)
533+
self.assertFalse(error_message)

0 commit comments

Comments
 (0)