From 1b6ff72f0f53056622e8ba9cfa5924f228ffa7a0 Mon Sep 17 00:00:00 2001 From: Afsal Syed Date: Thu, 16 Jul 2026 23:21:47 +0530 Subject: [PATCH] test(stock): add portal user contact link verification for customer and supplier test(stock): add portal user contact link verification for customer and supplier --- .../buying/doctype/supplier/test_supplier.py | 21 ++++++++++++++ .../selling/doctype/customer/test_customer.py | 28 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index 04983721a64..719770a6853 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -208,3 +208,24 @@ class TestSupplierPortal(FrappeTestCase): _, suppliers = get_customers_suppliers("Purchase Order", user) self.assertIn(supplier.name, suppliers) + + def test_portal_user_contact_link(self): + user_email = frappe.generate_hash() + "@example.com" + user = frappe.new_doc("User") + user.email = user_email + user.first_name = "Test Portal Contact User" + user.send_welcome_email = False + user.insert(ignore_permissions=True) + + contact = frappe.new_doc("Contact") + contact.first_name = "Test Portal Contact User" + contact.add_email(user_email, is_primary=1) + contact.links = [] + contact.insert(ignore_permissions=True) + + supplier = create_supplier() + supplier.append("portal_users", {"user": user.name}) + supplier.save() + + contact.reload() + self.assertTrue(contact.has_link("Supplier", supplier.name)) diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index a8fd5ed76ca..bfd66d51d24 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -386,6 +386,34 @@ class TestCustomer(FrappeTestCase): self.assertEqual(middle, "Michael") self.assertEqual(last, "Doe") + def test_portal_user_contact_link(self): + user_email = frappe.generate_hash() + "@example.com" + user = frappe.new_doc("User") + user.email = user_email + user.first_name = "Test Portal Customer User" + user.send_welcome_email = False + user.insert(ignore_permissions=True) + + contact = frappe.new_doc("Contact") + contact.first_name = "Test Portal Customer User" + contact.add_email(user_email, is_primary=1) + contact.links = [] + contact.insert(ignore_permissions=True) + + customer = frappe.get_doc( + { + "doctype": "Customer", + "customer_name": "Test Portal Contact Customer", + "customer_type": "Individual", + "customer_group": "_Test Customer Group", + } + ) + customer.append("portal_users", {"user": user.name}) + customer.insert() + + contact.reload() + self.assertTrue(contact.has_link("Customer", customer.name)) + def get_customer_dict(customer_name): return {