Skip to content

Commit f6b31d2

Browse files
committed
[IMP] l10n_it_fatturapa_in_purchase: test with intermediary wizard check
1 parent bc9aaee commit f6b31d2

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

l10n_it_fatturapa_in_purchase/tests/test_l10n_it_fatturapa_in_purchase.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,46 @@ def setUp(self):
3939
)
4040

4141
def test_fatturapa_in_purchase(self):
42-
"""Check that `name_get` works properly. verify to_invoice field"""
42+
"""
43+
Check that `name_get` works properly and verify the `to_invoice` field.
44+
Handle the intermediary VAT check wizard if triggered during import.
45+
"""
4346
res = self.run_wizard("test_fatturapa_in_purchase", "IT05979361218_008.xml")
44-
invoice_id = res.get("domain")[0][2][0]
45-
invoice = self.invoice_model.browse(invoice_id)
4647

48+
# Handle the intermediary VAT check wizard if it appears
49+
if res.get("res_model") == "wizard.check.intermediary":
50+
context = res.get("context", {})
51+
intermediary_id = context.get("intermediary_id")
52+
invoice_id = context.get("invoice_id")
53+
54+
self.assertTrue(intermediary_id, "intermediary_id is missing in context")
55+
self.assertTrue(invoice_id, "invoice_id is missing in context")
56+
57+
wizard = (
58+
self.env["wizard.check.intermediary"]
59+
.with_context(context)
60+
.create(
61+
{
62+
"message": context.get("default_message"),
63+
"intermediary_id": intermediary_id,
64+
"invoice_id": invoice_id,
65+
}
66+
)
67+
)
68+
69+
wizard.action_confirm()
70+
invoice = self.env["account.move"].browse(invoice_id)
71+
72+
else:
73+
invoice_id = res.get("domain")[0][2][0]
74+
invoice = self.invoice_model.browse(invoice_id)
75+
76+
# Link the invoice line to the purchase order line
4777
inv_line = first(invoice.invoice_line_ids)
4878
order_line = first(self.order.order_line)
4979
inv_line.purchase_line_id = order_line
5080

81+
# Check the display name and `to_invoice` field logic
5182
self.assertEqual(order_line.display_name, "test_po: Large Desk")
5283
self.assertFalse(order_line.to_invoice)
5384
order_line.product_id.write({"purchase_method": "purchase"})

0 commit comments

Comments
 (0)