* fix: Supplier users not able to see RFQ on the Portal (#40161) (cherry picked from commit f8ba560394f1c5dca38c28b9d97809fa964f50ec) * chore: fix travis --------- Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
parent
84a359c760
commit
6a63a6c98a
@ -205,10 +205,30 @@ class RequestforQuotation(BuyingController):
|
||||
|
||||
contact.save(ignore_permissions=True)
|
||||
|
||||
if rfq_supplier.supplier:
|
||||
self.update_user_in_supplier(rfq_supplier.supplier, user.name)
|
||||
|
||||
if not rfq_supplier.contact:
|
||||
# return contact to later update, RFQ supplier row's contact
|
||||
return contact.name
|
||||
|
||||
def update_user_in_supplier(self, supplier, user):
|
||||
"""Update user in Supplier."""
|
||||
if not frappe.db.exists("Portal User", {"parent": supplier, "user": user}):
|
||||
supplier_doc = frappe.get_doc("Supplier", supplier)
|
||||
supplier_doc.append(
|
||||
"portal_users",
|
||||
{
|
||||
"user": user,
|
||||
},
|
||||
)
|
||||
|
||||
supplier_doc.flags.ignore_validate = True
|
||||
supplier_doc.flags.ignore_mandatory = True
|
||||
supplier_doc.flags.ignore_permissions = True
|
||||
|
||||
supplier_doc.save()
|
||||
|
||||
def create_user(self, rfq_supplier, link):
|
||||
user = frappe.get_doc(
|
||||
{
|
||||
@ -245,6 +265,10 @@ class RequestforQuotation(BuyingController):
|
||||
"user_fullname": full_name,
|
||||
}
|
||||
)
|
||||
|
||||
if not self.email_template:
|
||||
return
|
||||
|
||||
email_template = frappe.get_doc("Email Template", self.email_template)
|
||||
message = frappe.render_template(email_template.response_, doc_args)
|
||||
subject = frappe.render_template(email_template.subject, doc_args)
|
||||
|
@ -138,6 +138,33 @@ class TestRequestforQuotation(FrappeTestCase):
|
||||
get_pdf(rfq.name, rfq.get("suppliers")[0].supplier)
|
||||
self.assertEqual(frappe.local.response.type, "pdf")
|
||||
|
||||
def test_portal_user_with_new_supplier(self):
|
||||
supplier_doc = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Supplier",
|
||||
"supplier_name": "Test Supplier for RFQ",
|
||||
"supplier_group": "_Test Supplier Group",
|
||||
}
|
||||
).insert()
|
||||
|
||||
self.assertFalse(supplier_doc.portal_users)
|
||||
|
||||
rfq = make_request_for_quotation(
|
||||
supplier_data=[
|
||||
{
|
||||
"supplier": supplier_doc.name,
|
||||
"supplier_name": supplier_doc.supplier_name,
|
||||
"email_id": "123_testrfquser@example.com",
|
||||
}
|
||||
],
|
||||
do_not_submit=True,
|
||||
)
|
||||
for rfq_supplier in rfq.suppliers:
|
||||
rfq.update_supplier_contact(rfq_supplier, rfq.get_link())
|
||||
|
||||
supplier_doc.reload()
|
||||
self.assertTrue(supplier_doc.portal_users[0].user)
|
||||
|
||||
|
||||
def make_request_for_quotation(**args) -> "RequestforQuotation":
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user