Skip to content

Commit c28b517

Browse files
committed
[IMP] l10n_it_fatturapa_in_purchase: test with intermediary wizard check
1 parent 240b4ee commit c28b517

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

l10n_it_fatturapa_in/security/ir.model.access.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ access_einvoice_line_other_data,access_einvoice_line_other_data,model_einvoice_l
66
access_wizard_import_fatturapa,access_wizard_import_fatturapa,model_wizard_import_fatturapa,account.group_account_invoice,1,1,1,1
77
access_wizard_link_to_invoice,access_wizard_link_to_invoice,model_wizard_link_to_invoice,account.group_account_invoice,1,1,1,1
88
access_wizard_link_to_invoice_line,access_wizard_link_to_invoice_line,model_wizard_link_to_invoice_line,account.group_account_invoice,1,1,1,1
9-
access_wizard_check_intermediary_all,access_wizard_check_intermediary_all,model_wizard_check_intermediary,,1,1,1,1
9+
access_wizard_check_intermediary_all,access_wizard_check_intermediary_all,model_wizard_check_intermediary,account.group_account_invoice,1,1,1,1
1010
fatturapa_in_decimal_precision_access_manager,fatturapa_in_decimal_precision_access_manager,base.model_decimal_precision,account.group_account_manager,1,1,0,0
1111
fatturapa_in_decimal_precision_access_billing,fatturapa_in_decimal_precision_access_billing,base.model_decimal_precision,account.group_account_invoice,1,1,0,0
1212
fatturapa_in_mail_followers_access_manager,fatturapa_in_mail_followers_access_manager,mail.model_mail_followers,account.group_account_manager,1,1,0,0

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)