[enhance] added roles for portal users frappe/frappe#2091 (#6452)

This commit is contained in:
Rushabh Mehta 2016-09-23 21:51:51 +05:30 committed by GitHub
parent 5f825deadd
commit fc800b3f2f
6 changed files with 49 additions and 16 deletions

View File

@ -14,7 +14,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
},
{
"fieldname": "based_on",
"label": __("Baed On"),
"label": __("Based On"),
"fieldtype": "Select",
"options": "Cost Center\nProject",
"default": "Cost Center",

View File

@ -101,17 +101,25 @@ website_route_rules = [
portal_menu_items = [
{"title": _("Projects"), "route": "/project", "reference_doctype": "Project"},
{"title": _("Request for Quotations"), "route": "/rfq", "reference_doctype": "Request for Quotation"},
{"title": _("Supplier Quotation"), "route": "/quotations", "reference_doctype": "Supplier Quotation"},
{"title": _("Orders"), "route": "/orders", "reference_doctype": "Sales Order"},
{"title": _("Invoices"), "route": "/invoices", "reference_doctype": "Sales Invoice"},
{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note"},
{"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "show_always": True},
{"title": _("Request for Quotations"), "route": "/rfq", "reference_doctype": "Request for Quotation", "role": "Supplier"},
{"title": _("Supplier Quotation"), "route": "/quotations", "reference_doctype": "Supplier Quotation", "role": "Supplier"},
{"title": _("Orders"), "route": "/orders", "reference_doctype": "Sales Order", "role":"Customer"},
{"title": _("Invoices"), "route": "/invoices", "reference_doctype": "Sales Invoice", "role":"Customer"},
{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"},
{"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"},
{"title": _("Addresses"), "route": "/addresses", "reference_doctype": "Address"},
{"title": _("Announcements"), "route": "/announcement", "reference_doctype": "Announcement"},
{"title": _("Courses"), "route": "/course", "reference_doctype": "Course"},
{"title": _("Assessment Schedule"), "route": "/assessment", "reference_doctype": "Assessment"},
{"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees"}
{"title": _("Courses"), "route": "/course", "reference_doctype": "Course", "role":"Student"},
{"title": _("Assessment Schedule"), "route": "/assessment", "reference_doctype": "Assessment", "role":"Student"},
{"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"}
]
default_roles = [
{'role': 'Customer', 'doctype':'Contact', 'email_field': 'email_id',
'filters': {'ifnull(customer, "")': ('!=', '')}},
{'role': 'Supplier', 'doctype':'Contact', 'email_field': 'email_id',
'filters': {'ifnull(supplier, "")': ('!=', '')}},
{'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'}
]
has_website_permission = {

View File

@ -328,3 +328,4 @@ erpnext.patches.v7_1.fix_link_for_customer_from_lead
erpnext.patches.v7_0.update_mode_of_payment_type
execute:frappe.reload_doctype("Salary Slip")
execute:frappe.db.sql("update `tabSalary Slip` set posting_date=creation")
erpnext.patches.v7_1.update_portal_roles

View File

@ -0,0 +1,18 @@
import frappe
def execute():
frappe.reload_doctype('Role')
for role_name in ('Customer', 'Supplier', 'Student'):
if frappe.db.exists('Role', role_name):
frappe.db.set_value('Role', role_name, 'desk_access', 0)
else:
frappe.get_doc(dict(doctype='Role', role_name=role_name, desk_access=0)).insert()
# set customer, supplier roles
for c in frappe.get_all('Contact', fields=['user'], filters={'ifnull(user, "")': ('!=', '')}):
user = frappe.get_doc('User', c.user)
user.set_default_roles()
user.save()

View File

@ -18,7 +18,7 @@ def get_domain(domain):
'set_value': [
['Stock Settings', None, 'show_barcode_field', 1]
],
'remove_sidebar_items': ['/announcement', '/course', '/assessment', '/fees']
'default_portal_role': 'Customer'
},
'Retail': {
@ -32,7 +32,7 @@ def get_domain(domain):
'set_value': [
['Stock Settings', None, 'show_barcode_field', 1]
],
'remove_sidebar_items': ['/announcement', '/course', '/assessment', '/fees']
'default_portal_role': 'Customer'
},
'Distribution': {
@ -45,7 +45,7 @@ def get_domain(domain):
'set_value': [
['Stock Settings', None, 'show_barcode_field', 1]
],
'remove_sidebar_items': ['/announcement', '/course', '/assessment', '/fees']
'default_portal_role': 'Customer'
},
'Services': {
@ -58,14 +58,15 @@ def get_domain(domain):
'set_value': [
['Stock Settings', None, 'show_barcode_field', 0]
],
'remove_sidebar_items': ['/announcement', '/course', '/assessment', '/fees']
'default_portal_role': 'Customer'
},
'Education': {
'desktop_icons': ['Student', 'Program', 'Course', 'Student Group', 'Instructor',
'Fees', 'ToDo', 'Schools'],
'allow_roles': ['Academics User', 'Accounts User', 'Accounts Manager', 'Item Manager',
'Website Manager', 'HR User', 'HR Manager', 'Purchase User', 'Purchase Manager'],
'allow_sidebar_items': ['/announcement', '/course', '/assessment', '/fees']
'Website Manager', 'HR User', 'HR Manager', 'Purchase User', 'Purchase Manager',
'Student'],
'default_portal_role': 'Student'
},
}
if not domain in data:
@ -80,6 +81,8 @@ def setup_domain(domain):
setup_properties(data)
set_values(data)
setup_sidebar_items(data)
if data.get('default_portal_role'):
frappe.db.set_value('Portal Settings', None, 'default_role', data.get('default_portal_role'))
frappe.clear_cache()
def setup_desktop_icons(data):

View File

@ -13,6 +13,9 @@ default_lead_sources = ["Existing Customer", "Reference", "Advertisement",
def install(country=None):
records = [
dict(doctype='Role', role_name='Supplier', desk_access=0),
dict(doctype='Role', role_name='Customer', desk_access=0),
dict(doctype='Role', role_name='Student', desk_access=0),
# address template
{'doctype':"Address Template", "country": country},