mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
[permission model] Redesign
Conflicts: patches/patch_list.py
This commit is contained in:
committed by
Anand Doshi
parent
74f64b67db
commit
497d363fc1
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-30 12:49:46",
|
"creation": "2013-01-30 12:49:46",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-09-24 11:22:18",
|
"modified": "2013-11-26 17:35:12",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -138,6 +138,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "parent_account",
|
"fieldname": "parent_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "Parent Account",
|
"label": "Parent Account",
|
||||||
"oldfieldname": "parent_account",
|
"oldfieldname": "parent_account",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@@ -154,7 +155,6 @@
|
|||||||
"oldfieldname": "account_type",
|
"oldfieldname": "account_type",
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"options": "\nFixed Asset Account\nBank or Cash\nExpense Account\nTax\nIncome Account\nChargeable\nWarehouse",
|
"options": "\nFixed Asset Account\nBank or Cash\nExpense Account\nTax\nIncome Account\nChargeable\nWarehouse",
|
||||||
"permlevel": 0,
|
|
||||||
"search_index": 0
|
"search_index": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-23 19:57:17",
|
"creation": "2013-01-23 19:57:17",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-07-22 15:23:10",
|
"modified": "2013-11-26 17:34:50",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -74,6 +74,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "parent_cost_center",
|
"fieldname": "parent_cost_center",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "Parent Cost Center",
|
"label": "Parent Cost Center",
|
||||||
"oldfieldname": "parent_cost_center",
|
"oldfieldname": "parent_cost_center",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@@ -171,6 +172,7 @@
|
|||||||
"fieldname": "old_parent",
|
"fieldname": "old_parent",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "old_parent",
|
"label": "old_parent",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "old_parent",
|
"oldfieldname": "old_parent",
|
||||||
|
|||||||
@@ -43,9 +43,11 @@ class DocType:
|
|||||||
self.update_profile()
|
self.update_profile()
|
||||||
|
|
||||||
def update_user_default(self):
|
def update_user_default(self):
|
||||||
|
if not "HR User" in webnotes.local.user.get_roles():
|
||||||
|
webnotes.conn.set_default("Employee", self.doc.name, self.doc.user_id, "Restriction")
|
||||||
|
|
||||||
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
|
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
|
||||||
webnotes.conn.set_default("employee_name", self.doc.employee_name, self.doc.user_id)
|
webnotes.conn.set_default("employee_name", self.doc.employee_name, self.doc.user_id)
|
||||||
webnotes.conn.set_default("company", self.doc.company, self.doc.user_id)
|
|
||||||
self.set_default_leave_approver()
|
self.set_default_leave_approver()
|
||||||
|
|
||||||
def set_default_leave_approver(self):
|
def set_default_leave_approver(self):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-07 09:04:18",
|
"creation": "2013-03-07 09:04:18",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-11-03 11:19:10",
|
"modified": "2013-11-26 16:36:34",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -415,6 +415,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "reports_to",
|
"fieldname": "reports_to",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "Reports to",
|
"label": "Reports to",
|
||||||
"oldfieldname": "reports_to",
|
"oldfieldname": "reports_to",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@@ -749,7 +750,6 @@
|
|||||||
"cancel": 0,
|
"cancel": 0,
|
||||||
"create": 0,
|
"create": 0,
|
||||||
"doctype": "DocPerm",
|
"doctype": "DocPerm",
|
||||||
"match": "employee",
|
|
||||||
"role": "Employee",
|
"role": "Employee",
|
||||||
"write": 0
|
"write": 0
|
||||||
},
|
},
|
||||||
@@ -757,7 +757,6 @@
|
|||||||
"cancel": 1,
|
"cancel": 1,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"doctype": "DocPerm",
|
"doctype": "DocPerm",
|
||||||
"match": "company",
|
|
||||||
"role": "HR User",
|
"role": "HR User",
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
|
|||||||
38
patches/1311/p06_update_user_properties.py
Normal file
38
patches/1311/p06_update_user_properties.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import webnotes
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
update_user_properties()
|
||||||
|
update_permissions()
|
||||||
|
webnotes.clear_cache()
|
||||||
|
|
||||||
|
def update_user_properties():
|
||||||
|
webnotes.reload_doc("core", "doctype", "docfield")
|
||||||
|
|
||||||
|
for d in webnotes.conn.sql("""select parent, defkey, defvalue from tabDefaultValue
|
||||||
|
where parent not in ('__global', 'Control Panel')""", as_dict=True):
|
||||||
|
df = webnotes.conn.sql("""select options from tabDocField
|
||||||
|
where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True)
|
||||||
|
|
||||||
|
if df:
|
||||||
|
webnotes.conn.sql("""update tabDefaultValue
|
||||||
|
set defkey=%s, parenttype='Restriction'
|
||||||
|
where defkey=%s and
|
||||||
|
parent not in ('__global', 'Control Panel')""", (df[0].options, d.defkey))
|
||||||
|
|
||||||
|
# remove duplicate restrictions (if they exist)
|
||||||
|
for d in webnotes.conn.sql("""select parent, defkey, substr(defvalue,0,10),
|
||||||
|
count(*) as cnt from tabDefaultValue
|
||||||
|
where parent not in ('__global', 'Control Panel')
|
||||||
|
group by parent, defkey, defvalue""", as_dict=1):
|
||||||
|
if d.cnt > 1:
|
||||||
|
webnotes.conn.sql("""delete from tabDefaultValue where parent=%s, defkey=%s,
|
||||||
|
defvalue=%s limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1))
|
||||||
|
|
||||||
|
def update_permissions():
|
||||||
|
# clear match conditions other than owner
|
||||||
|
webnotes.conn.sql("""update tabDocPerm set `match`=''
|
||||||
|
where ifnull(`match`,'') not in ('', 'owner')""")
|
||||||
@@ -254,6 +254,7 @@ patch_list = [
|
|||||||
"patches.1311.p04_update_comments",
|
"patches.1311.p04_update_comments",
|
||||||
"patches.1311.p05_website_brand_html",
|
"patches.1311.p05_website_brand_html",
|
||||||
"patches.1311.p06_fix_report_columns",
|
"patches.1311.p06_fix_report_columns",
|
||||||
|
"patches.1311.p06_update_user_properties",
|
||||||
"execute:webnotes.delete_doc('DocType', 'Documentation Tool')",
|
"execute:webnotes.delete_doc('DocType', 'Documentation Tool')",
|
||||||
"execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29",
|
"execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29",
|
||||||
"patches.1312.p01_delete_old_stock_reports",
|
"patches.1312.p01_delete_old_stock_reports",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-10 16:34:23",
|
"creation": "2013-01-10 16:34:23",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-11-02 16:52:51",
|
"modified": "2013-11-26 17:35:45",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "parent_customer_group",
|
"fieldname": "parent_customer_group",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "Parent Customer Group",
|
"label": "Parent Customer Group",
|
||||||
"oldfieldname": "parent_customer_group",
|
"oldfieldname": "parent_customer_group",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@@ -127,6 +128,7 @@
|
|||||||
"fieldname": "old_parent",
|
"fieldname": "old_parent",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "old_parent",
|
"label": "old_parent",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "old_parent",
|
"oldfieldname": "old_parent",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-28 10:35:29",
|
"creation": "2013-03-28 10:35:29",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-11-02 19:41:37",
|
"modified": "2013-11-26 17:36:08",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "parent_item_group",
|
"fieldname": "parent_item_group",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "Parent Item Group",
|
"label": "Parent Item Group",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "parent_item_group",
|
"oldfieldname": "parent_item_group",
|
||||||
@@ -166,6 +167,7 @@
|
|||||||
"fieldname": "old_parent",
|
"fieldname": "old_parent",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "old_parent",
|
"label": "old_parent",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "old_parent",
|
"oldfieldname": "old_parent",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-10 16:34:24",
|
"creation": "2013-01-10 16:34:24",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-09-10 10:53:28",
|
"modified": "2013-11-26 17:35:29",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "parent_sales_person",
|
"fieldname": "parent_sales_person",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "Parent Sales Person",
|
"label": "Parent Sales Person",
|
||||||
"oldfieldname": "parent_sales_person",
|
"oldfieldname": "parent_sales_person",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-10 16:34:24",
|
"creation": "2013-01-10 16:34:24",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-11-02 16:59:08",
|
"modified": "2013-11-26 17:36:23",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -68,6 +68,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "parent_territory",
|
"fieldname": "parent_territory",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "Parent Territory",
|
"label": "Parent Territory",
|
||||||
"oldfieldname": "parent_territory",
|
"oldfieldname": "parent_territory",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@@ -136,6 +137,7 @@
|
|||||||
"fieldname": "old_parent",
|
"fieldname": "old_parent",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
|
"ignore_restriction": 1,
|
||||||
"label": "old_parent",
|
"label": "old_parent",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "old_parent",
|
"oldfieldname": "old_parent",
|
||||||
|
|||||||
Reference in New Issue
Block a user