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 19, 2025
1 parent 240b4ee commit c28b517
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_in/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ access_einvoice_line_other_data,access_einvoice_line_other_data,model_einvoice_l
access_wizard_import_fatturapa,access_wizard_import_fatturapa,model_wizard_import_fatturapa,account.group_account_invoice,1,1,1,1
access_wizard_link_to_invoice,access_wizard_link_to_invoice,model_wizard_link_to_invoice,account.group_account_invoice,1,1,1,1
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
access_wizard_check_intermediary_all,access_wizard_check_intermediary_all,model_wizard_check_intermediary,,1,1,1,1
access_wizard_check_intermediary_all,access_wizard_check_intermediary_all,model_wizard_check_intermediary,account.group_account_invoice,1,1,1,1
fatturapa_in_decimal_precision_access_manager,fatturapa_in_decimal_precision_access_manager,base.model_decimal_precision,account.group_account_manager,1,1,0,0
fatturapa_in_decimal_precision_access_billing,fatturapa_in_decimal_precision_access_billing,base.model_decimal_precision,account.group_account_invoice,1,1,0,0
fatturapa_in_mail_followers_access_manager,fatturapa_in_mail_followers_access_manager,mail.model_mail_followers,account.group_account_manager,1,1,0,0
Expand Down
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 c28b517

Please sign in to comment.