Role and User Permissions

This commit is contained in:
Anand Doshi 2014-05-27 18:41:01 +05:30
parent a8ce570635
commit 69eec9e344
8 changed files with 39 additions and 49 deletions

View File

@ -87,6 +87,7 @@
"description": "System User (login) ID. If set, it will become default for all HR forms.",
"fieldname": "user_id",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "User ID",
"options": "User",
"permlevel": 0
@ -672,7 +673,7 @@
],
"icon": "icon-user",
"idx": 1,
"modified": "2014-05-27 03:49:10.297398",
"modified": "2014-05-27 07:34:49.337586",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",

View File

@ -874,7 +874,7 @@
"idx": 1,
"is_submittable": 1,
"issingle": 0,
"modified": "2014-05-27 03:49:18.266089",
"modified": "2014-05-27 08:39:19.027965",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",
@ -895,6 +895,23 @@
"submit": 1,
"write": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"import": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales Manager",
"set_user_permissions": 1,
"submit": 1,
"write": 1
},
{
"amend": 1,
"apply_user_permissions": 1,

View File

@ -3,6 +3,7 @@
import frappe
from frappe.utils import flt
import frappe.permissions
import unittest
import copy
@ -283,12 +284,17 @@ class TestSalesOrder(unittest.TestCase):
so.get("sales_order_details")[0].warehouse, 20.0)
def test_warehouse_user(self):
frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "User Permission")
frappe.get_doc("User", "test@example.com")\
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
frappe.permissions.add_user_permission("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com")
frappe.permissions.add_user_permission("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com")
frappe.permissions.add_user_permission("Company", "_Test Company 1", "test2@example.com")
frappe.get_doc("User", "test2@example.com")\
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
test_user = frappe.get_doc("User", "test@example.com")
test_user.add_roles("Sales User", "Material User")
test_user.remove_roles("Sales Manager")
test_user_2 = frappe.get_doc("User", "test2@example.com")
test_user_2.add_roles("Sales User", "Material User")
test_user_2.remove_roles("Sales Manager")
frappe.set_user("test@example.com")
@ -302,7 +308,9 @@ class TestSalesOrder(unittest.TestCase):
frappe.set_user("test2@example.com")
so.insert()
frappe.defaults.clear_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", parenttype="User Permission")
frappe.permissions.remove_user_permission("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com")
frappe.permissions.remove_user_permission("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com")
frappe.permissions.remove_user_permission("Company", "_Test Company 1", "test2@example.com")
test_dependencies = ["Sales BOM", "Currency Exchange"]

View File

@ -776,8 +776,10 @@ class TestStockEntry(unittest.TestCase):
frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC", "test@example.com", "User Permission")
frappe.defaults.add_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", "User Permission")
frappe.get_doc("User", "test@example.com")\
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
test_user = frappe.get_doc("User", "test@example.com")
test_user.add_roles("Sales User", "Sales Manager", "Material User")
test_user.remove_roles("Material Manager")
frappe.get_doc("User", "test2@example.com")\
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
@ -799,7 +801,7 @@ class TestStockEntry(unittest.TestCase):
frappe.defaults.clear_default("Warehouse", "_Test Warehouse 2 - _TC1",
"test2@example.com", parenttype="User Permission")
def test_freeze_stocks (self):
def test_freeze_stocks(self):
self._clear_stock_account_balance()
frappe.db.set_value('Stock Settings', None,'stock_auth_role', '')

View File

@ -1 +0,0 @@
If specified, only user defined in this table are allowed to transact on the parent Warehouse.

View File

@ -1,25 +0,0 @@
{
"creation": "2013-02-22 01:28:05.000000",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Other",
"fields": [
{
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"label": "User",
"options": "User",
"permlevel": 0,
"print_width": "200px",
"width": "200px"
}
],
"idx": 1,
"istable": 1,
"modified": "2013-12-20 19:21:54.000000",
"modified_by": "Administrator",
"module": "Stock",
"name": "Warehouse User",
"owner": "Administrator"
}

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class WarehouseUser(Document):
pass