Skip to content

Commit

Permalink
[IMP] l10n_it_fatturapa_in_purchase: test with intermediary wizard check
Browse files Browse the repository at this point in the history
  • Loading branch information
Chionne27 committed Feb 24, 2025
1 parent 718d373 commit 1e7be0b
Showing 1 changed file with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,46 @@ def setUp(self):
)

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

# Handle the intermediary VAT check wizard if it appears
if res.get("res_model") == "wizard.check.intermediary":
context = res.get("context", {})
intermediary_id = context.get("intermediary_id")
invoice_id = context.get("invoice_id")

self.assertTrue(intermediary_id, "intermediary_id is missing in context")
self.assertTrue(invoice_id, "invoice_id is missing in context")

wizard = (
self.env["wizard.check.intermediary"]
.with_context(context)
.create(
{
"message": context.get("default_message"),
"intermediary_id": intermediary_id,
"invoice_id": invoice_id,
}
)
)

wizard.action_confirm()
invoice = self.env["account.move"].browse(invoice_id)

else:
invoice_id = res.get("domain")[0][2][0]
invoice = self.invoice_model.browse(invoice_id)

Check warning on line 74 in l10n_it_fatturapa_in_purchase/tests/test_l10n_it_fatturapa_in_purchase.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_in_purchase/tests/test_l10n_it_fatturapa_in_purchase.py#L73-L74

Added lines #L73 - L74 were not covered by tests

# Link the invoice line to the purchase order line
inv_line = first(invoice.invoice_line_ids)
order_line = first(self.order.order_line)
inv_line.purchase_line_id = order_line

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

0 comments on commit 1e7be0b

Please sign in to comment.