mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 22:19:18 +00:00
fix!: UX of supplier linking with supplier users on portal pages (#35836)
* fix: create and add Portal Users child table in Supplier/Customer Issue #35772 * fix: modify the original permission check hook * fix: auto-add role for portal users * fix: added patch for auto-populating portal users * fix: modify patch to fetch users correctly * fix: remove unnecessary code for updating naming_series * fix(UX): show portal user in list view Also split columns to reduce whitespace. * refactor: simpler role checking * fix: consider parenttype while fetching portal user * refactor: simpler code, rename variable * test: supplier portal user can access their docs * refactor: only add role if not added * refactor: rename and move patch to supplier * refactor: dont add role if no perm or existing doc * fix: add role before save * refactor: run query directly * refactor: split patch and apply roles - if role isn't present dont add portal user - ignore failure as it's not critical * test: fix permission creation for webform test --------- Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
committed by
GitHub
parent
e832455790
commit
5113a417a1
@@ -3,18 +3,21 @@ import unittest
|
||||
import frappe
|
||||
|
||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||
from erpnext.buying.doctype.supplier.test_supplier import create_supplier
|
||||
|
||||
|
||||
class TestWebsite(unittest.TestCase):
|
||||
def test_permission_for_custom_doctype(self):
|
||||
create_user("Supplier 1", "supplier1@gmail.com")
|
||||
create_user("Supplier 2", "supplier2@gmail.com")
|
||||
create_supplier_with_contact(
|
||||
"Supplier1", "All Supplier Groups", "Supplier 1", "supplier1@gmail.com"
|
||||
)
|
||||
create_supplier_with_contact(
|
||||
"Supplier2", "All Supplier Groups", "Supplier 2", "supplier2@gmail.com"
|
||||
)
|
||||
|
||||
supplier1 = create_supplier(supplier_name="Supplier1")
|
||||
supplier2 = create_supplier(supplier_name="Supplier2")
|
||||
supplier1.append("portal_users", {"user": "supplier1@gmail.com"})
|
||||
supplier1.save()
|
||||
supplier2.append("portal_users", {"user": "supplier2@gmail.com"})
|
||||
supplier2.save()
|
||||
|
||||
po1 = create_purchase_order(supplier="Supplier1")
|
||||
po2 = create_purchase_order(supplier="Supplier2")
|
||||
|
||||
@@ -61,21 +64,6 @@ def create_user(name, email):
|
||||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
|
||||
def create_supplier_with_contact(name, group, contact_name, contact_email):
|
||||
supplier = frappe.get_doc(
|
||||
{"doctype": "Supplier", "supplier_name": name, "supplier_group": group}
|
||||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
if not frappe.db.exists("Contact", contact_name + "-1-" + name):
|
||||
new_contact = frappe.new_doc("Contact")
|
||||
new_contact.first_name = contact_name
|
||||
new_contact.is_primary_contact = (True,)
|
||||
new_contact.append("links", {"link_doctype": "Supplier", "link_name": supplier.name})
|
||||
new_contact.append("email_ids", {"email_id": contact_email, "is_primary": 1})
|
||||
|
||||
new_contact.insert(ignore_mandatory=True)
|
||||
|
||||
|
||||
def create_custom_doctype():
|
||||
frappe.get_doc(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user