From f043353880a0762592fad2acdcc51ab2a9cd3fbb Mon Sep 17 00:00:00 2001 From: Paolo Gatti Date: Mon, 25 Mar 2024 17:03:19 +0100 Subject: [PATCH] [IMP] l10n_it_edi: Adding negative bill test Added a test to verify the behaviour when receiving a negative bill. The invoice gets imported with negative amounts, but it can't be posted. When the user tries to post it, they are prompted to turn it into a credit note with a UserError. closes odoo/odoo#141485 Signed-off-by: Josse Colpaert --- .../tests/import_xmls/IT01234567890_FPR02.xml | 111 ++++++++++++++++++ addons/l10n_it_edi/tests/test_edi_import.py | 16 +++ 2 files changed, 127 insertions(+) create mode 100644 addons/l10n_it_edi/tests/import_xmls/IT01234567890_FPR02.xml diff --git a/addons/l10n_it_edi/tests/import_xmls/IT01234567890_FPR02.xml b/addons/l10n_it_edi/tests/import_xmls/IT01234567890_FPR02.xml new file mode 100644 index 00000000000..1005e4e9528 --- /dev/null +++ b/addons/l10n_it_edi/tests/import_xmls/IT01234567890_FPR02.xml @@ -0,0 +1,111 @@ + + + + + IT + 01234560157 + + 00001 + FPR12 + ABC1234 + + + + + + IT + 01234560157 + + + SOCIETA' ALPHA SRL + + RF19 + + + VIALE ROMA 543 + 07100 + SASSARI + SS + IT + + + + + 01234560157 + + DITTA BETA + + + + VIA TORINO 38-B + 00145 + ROMA + RM + IT + + + + + + + TD01 + EUR + 2014-12-18 + 01234567890 + Test + + + 1 + 66685 + 1 + + + 1 + 01234567890 + 2012-09-01 + 5 + 01234567890abc + 456def + + + + + IT + 24681012141 + + + Trasporto spa + + + 2012-10-22T16:46:12.000+02:00 + + + + + 1 + DESCRIZIONE DELLA FORNITURA + 5.00 + -1.00 + -5.00 + 22.00 + + + 22.00 + -5.00 + -1.10 + I + + + + TP01 + + MP01 + 2015-01-30 + -6.10 + + + + diff --git a/addons/l10n_it_edi/tests/test_edi_import.py b/addons/l10n_it_edi/tests/test_edi_import.py index 1da8ec87de8..c70ddc9bcb7 100644 --- a/addons/l10n_it_edi/tests/test_edi_import.py +++ b/addons/l10n_it_edi/tests/test_edi_import.py @@ -47,12 +47,28 @@ class TestItEdiImport(TestItEdi): https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2/IT01234567890_FPR01.xml """ self._assert_import_invoice('IT01234567890_FPR01.xml', [{ + 'move_type': 'in_invoice', 'invoice_date': fields.Date.from_string('2014-12-18'), 'amount_untaxed': 5.0, 'amount_tax': 1.1, 'invoice_line_ids': [{ 'quantity': 5.0, 'price_unit': 1.0, + 'debit': 5.0, + }], + }]) + + def test_receive_negative_vendor_bill(self): + """ Same vendor bill as test_receive_vendor_bill but negative unit price """ + self._assert_import_invoice('IT01234567890_FPR02.xml', [{ + 'move_type': 'in_invoice', + 'invoice_date': fields.Date.from_string('2014-12-18'), + 'amount_untaxed': -5.0, + 'amount_tax': -1.1, + 'invoice_line_ids': [{ + 'quantity': 5.0, + 'price_unit': -1.0, + 'credit': 5.0, }], }])