remove apply user permission (#13505)
This commit is contained in:
parent
0e3b000e81
commit
97d84eb509
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,7 @@ class Employee(NestedSet):
|
||||
self.validate_status()
|
||||
self.validate_employee_leave_approver()
|
||||
self.validate_reports_to()
|
||||
self.validate_prefered_email()
|
||||
self.validate_preferred_email()
|
||||
|
||||
if self.user_id:
|
||||
self.validate_for_enabled_user_id()
|
||||
@ -63,6 +63,7 @@ class Employee(NestedSet):
|
||||
self.update_user_permissions()
|
||||
|
||||
def update_user_permissions(self):
|
||||
if not self.create_user_permission: return
|
||||
frappe.permissions.add_user_permission("Employee", self.name, self.user_id)
|
||||
frappe.permissions.set_user_permission_if_allowed("Company", self.company, self.user_id)
|
||||
|
||||
@ -162,7 +163,7 @@ class Employee(NestedSet):
|
||||
self.update_nsm_model()
|
||||
delete_events(self.doctype, self.name)
|
||||
|
||||
def validate_prefered_email(self):
|
||||
def validate_preferred_email(self):
|
||||
if self.prefered_contact_email and not self.get(scrub(self.prefered_contact_email)):
|
||||
frappe.msgprint(_("Please enter " + self.prefered_contact_email))
|
||||
|
||||
|
@ -15,10 +15,11 @@ def update_hr_permissions():
|
||||
# add set user permissions rights to HR Manager
|
||||
frappe.db.sql("""update `tabDocPerm` set `set_user_permissions`=1 where parent in ('Employee', 'Leave Application')
|
||||
and role='HR Manager' and permlevel=0 and `read`=1""")
|
||||
|
||||
# apply user permissions on Employee and Leave Application
|
||||
frappe.db.sql("""update `tabDocPerm` set `apply_user_permissions`=1 where parent in ('Employee', 'Leave Application')
|
||||
and role in ('Employee', 'Leave Approver') and permlevel=0 and `read`=1""")
|
||||
docperm_meta = frappe.get_meta('DocPerm')
|
||||
if docperm_meta.get_field('apply_user_permissions'):
|
||||
# apply user permissions on Employee and Leave Application
|
||||
frappe.db.sql("""update `tabDocPerm` set `apply_user_permissions`=1 where parent in ('Employee', 'Leave Application')
|
||||
and role in ('Employee', 'Leave Approver') and permlevel=0 and `read`=1""")
|
||||
|
||||
frappe.clear_cache()
|
||||
|
||||
|
@ -8,18 +8,13 @@ import unittest
|
||||
from erpnext.selling.doctype.sales_order.sales_order \
|
||||
import make_material_request, make_delivery_note, make_sales_invoice, WarehouseRequired
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||
from frappe.tests.test_permissions import set_user_permission_doctypes
|
||||
from erpnext.selling.doctype.sales_order.sales_order import make_work_orders
|
||||
import json
|
||||
|
||||
|
||||
class TestSalesOrder(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
frappe.set_user("Administrator")
|
||||
|
||||
for role in ("Stock User", "Sales User"):
|
||||
set_user_permission_doctypes(doctypes="Sales Order", role=role,
|
||||
apply_user_permissions=0, user_permission_doctypes=None)
|
||||
pass
|
||||
|
||||
def test_make_material_request(self):
|
||||
so = make_sales_order(do_not_submit=True)
|
||||
@ -259,10 +254,6 @@ class TestSalesOrder(unittest.TestCase):
|
||||
existing_reserved_qty_item2 + 20)
|
||||
|
||||
def test_warehouse_user(self):
|
||||
for role in ("Stock User", "Sales User"):
|
||||
set_user_permission_doctypes(doctypes="Sales Order", role=role,
|
||||
apply_user_permissions=1, user_permission_doctypes=["Warehouse"])
|
||||
|
||||
frappe.permissions.add_user_permission("Warehouse", "_Test Warehouse 1 - _TC", "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")
|
||||
|
@ -12,7 +12,6 @@ from erpnext.stock.doctype.stock_ledger_entry.stock_ledger_entry import StockFre
|
||||
from erpnext.stock.stock_ledger import get_previous_sle
|
||||
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import create_stock_reconciliation
|
||||
from erpnext.stock.doctype.item.test_item import set_item_variant_settings, make_item_variant, create_item
|
||||
from frappe.tests.test_permissions import set_user_permission_doctypes
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry import move_sample_to_retention_warehouse
|
||||
@ -35,10 +34,6 @@ class TestStockEntry(unittest.TestCase):
|
||||
frappe.set_user("Administrator")
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
for role in ("Stock User", "Sales User"):
|
||||
set_user_permission_doctypes(doctypes="Stock Entry", role=role,
|
||||
apply_user_permissions=0, user_permission_doctypes=None)
|
||||
|
||||
def test_fifo(self):
|
||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
||||
item_code = "_Test Item 2"
|
||||
@ -485,10 +480,6 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
# permission tests
|
||||
def test_warehouse_user(self):
|
||||
for role in ("Stock User", "Sales User"):
|
||||
set_user_permission_doctypes(doctypes="Stock Entry", role=role,
|
||||
apply_user_permissions=1, user_permission_doctypes=["Warehouse"])
|
||||
|
||||
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")
|
||||
test_user = frappe.get_doc("User", "test@example.com")
|
||||
@ -619,10 +610,10 @@ class TestStockEntry(unittest.TestCase):
|
||||
def test_retain_sample(self):
|
||||
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
|
||||
from erpnext.stock.doctype.batch.batch import get_batch_qty
|
||||
|
||||
|
||||
create_warehouse("Test Warehouse for Sample Retention")
|
||||
frappe.db.set_value("Stock Settings", None, "sample_retention_warehouse", "Test Warehouse for Sample Retention - _TC")
|
||||
|
||||
|
||||
item = frappe.new_doc("Item")
|
||||
item.item_code = "Retain Sample Item"
|
||||
item.item_name = "Retain Sample Item"
|
||||
@ -667,7 +658,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
qty_in_usable_warehouse = get_batch_qty(receipt_entry.get("items")[0].batch_no, "_Test Warehouse - _TC", "_Test Item")
|
||||
qty_in_retention_warehouse = get_batch_qty(receipt_entry.get("items")[0].batch_no, "Test Warehouse for Sample Retention - _TC", "_Test Item")
|
||||
|
||||
|
||||
self.assertEqual(qty_in_usable_warehouse, 36)
|
||||
self.assertEqual(qty_in_retention_warehouse, 4)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user