Skip to content

Commit

Permalink
Merge pull request #36218 from GursheenK/view-projects-in-customer-po…
Browse files Browse the repository at this point in the history
…rtal

fix: project routes and permissions in portal
  • Loading branch information
deepeshgarg007 committed Aug 25, 2023
2 parents e462edc + 5c48074 commit 57538bd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
3 changes: 2 additions & 1 deletion erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
]

standard_portal_menu_items = [
{"title": "Projects", "route": "/project", "reference_doctype": "Project"},
{"title": "Projects", "route": "/project", "reference_doctype": "Project", "role": "Customer"},
{
"title": "Request for Quotations",
"route": "/rfq",
Expand Down Expand Up @@ -290,6 +290,7 @@
"Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission",
"Issue": "erpnext.support.doctype.issue.issue.has_website_permission",
"Timesheet": "erpnext.controllers.website_list_for_contact.has_website_permission",
"Project": "erpnext.controllers.website_list_for_contact.has_website_permission",
}

before_tests = "erpnext.setup.utils.before_tests"
Expand Down
1 change: 1 addition & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ erpnext.patches.v15_0.saudi_depreciation_warning
erpnext.patches.v15_0.delete_saudi_doctypes
erpnext.patches.v14_0.show_loan_management_deprecation_warning
execute:frappe.rename_doc("Report", "TDS Payable Monthly", "Tax Withholding Details", force=True)
erpnext.patches.v14_0.delete_education_module_portal_menu_items

[post_model_sync]
execute:frappe.delete_doc_if_exists('Workspace', 'ERPNext Integrations Settings')
Expand Down
9 changes: 9 additions & 0 deletions erpnext/patches/v14_0/delete_education_doctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ def execute():
frappe.delete_doc("Number Card", card, ignore_missing=True, force=True)

doctypes = frappe.get_all("DocType", {"module": "education", "custom": 0}, pluck="name")

for doctype in doctypes:
frappe.delete_doc("DocType", doctype, ignore_missing=True)

portal_settings = frappe.get_doc("Portal Settings")

for row in portal_settings.get("menu"):
if row.reference_doctype in doctypes:
row.delete()

portal_settings.save()

frappe.delete_doc("Module Def", "Education", ignore_missing=True, force=True)

click.secho(
Expand Down
13 changes: 13 additions & 0 deletions erpnext/patches/v14_0/delete_education_module_portal_menu_items.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE

import frappe


def execute():
doctypes = frappe.get_all("DocType", {"module": "education", "custom": 0}, pluck="name")
items = frappe.get_all(
"Portal Menu Item", filters={"reference_doctype": ("in", doctypes)}, pluck="name"
)
for item in items:
frappe.delete_doc("Portal Menu Item", item, ignore_missing=True, force=True)
41 changes: 31 additions & 10 deletions erpnext/projects/doctype/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
from frappe.query_builder import Interval
from frappe.query_builder.functions import Count, CurDate, Date, UnixTimestamp
from frappe.utils import add_days, flt, get_datetime, get_time, get_url, nowtime, today
from frappe.utils.user import is_website_user

from erpnext import get_default_company
from erpnext.controllers.queries import get_filters_cond
from erpnext.controllers.website_list_for_contact import get_customers_suppliers
from erpnext.setup.doctype.holiday_list.holiday_list import is_holiday


Expand Down Expand Up @@ -318,9 +320,20 @@ def get_timeline_data(doctype: str, name: str) -> dict[int, int]:
def get_project_list(
doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"
):
user = frappe.session.user
customers, suppliers = get_customers_suppliers("Project", frappe.session.user)

ignore_permissions = False
if is_website_user():
if not filters:
filters = []

if customers:
filters.append([doctype, "customer", "in", customers])

ignore_permissions = True

meta = frappe.get_meta(doctype)
if not filters:
filters = []

fields = "distinct *"

Expand Down Expand Up @@ -351,18 +364,26 @@ def get_project_list(
limit_start=limit_start,
limit_page_length=limit_page_length,
order_by=order_by,
ignore_permissions=ignore_permissions,
)


def get_list_context(context=None):
return {
"show_sidebar": True,
"show_search": True,
"no_breadcrumbs": True,
"title": _("Projects"),
"get_list": get_project_list,
"row_template": "templates/includes/projects/project_row.html",
}
from erpnext.controllers.website_list_for_contact import get_list_context

list_context = get_list_context(context)
list_context.update(
{
"show_sidebar": True,
"show_search": True,
"no_breadcrumbs": True,
"title": _("Projects"),
"get_list": get_project_list,
"row_template": "templates/includes/projects/project_row.html",
}
)

return list_context


@frappe.whitelist()
Expand Down

0 comments on commit 57538bd

Please sign in to comment.