mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
[minor] user properties and leave application
This commit is contained in:
@@ -1,29 +0,0 @@
|
|||||||
select.accbrowser-company-select {
|
|
||||||
width: 200px;
|
|
||||||
margin-top: 2px;
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.tree-node-toolbar {
|
|
||||||
padding: 2px;
|
|
||||||
margin-left: 15px;
|
|
||||||
border-radius: 3px;
|
|
||||||
-moz-border-radius: 3px;
|
|
||||||
-webkit-border-radius: 3px;
|
|
||||||
border-radius: 3px;
|
|
||||||
background-color: #ddd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-area a.selected {
|
|
||||||
font-weight: bold;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.balance-area {
|
|
||||||
float: right;
|
|
||||||
height: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.balance-bold {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
// see ledger
|
// see ledger
|
||||||
|
|
||||||
pscript['onload_Accounts Browser'] = function(wrapper){
|
pscript['onload_Accounts Browser'] = function(wrapper){
|
||||||
console.log($(wrapper).html());
|
|
||||||
wn.ui.make_app_page({
|
wn.ui.make_app_page({
|
||||||
parent: wrapper,
|
parent: wrapper,
|
||||||
single_column: true
|
single_column: true
|
||||||
@@ -122,14 +121,14 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// bold
|
// bold
|
||||||
$('.balance-bold').removeClass('balance-bold'); // deselect
|
$('.bold').removeClass('bold'); // deselect
|
||||||
$(link).parent().find('.balance-area:first').addClass('balance-bold'); // select
|
$(link).parent().find('.balance-area:first').addClass('bold'); // select
|
||||||
|
|
||||||
},
|
},
|
||||||
onrender: function(treenode) {
|
onrender: function(treenode) {
|
||||||
if (ctype == 'Account' && treenode.data) {
|
if (ctype == 'Account' && treenode.data) {
|
||||||
if(treenode.data.balance) {
|
if(treenode.data.balance) {
|
||||||
treenode.parent.append('<span class="balance-area">'
|
treenode.parent.append('<span class="balance-area pull-right">'
|
||||||
+ format_currency(treenode.data.balance, treenode.data.currency)
|
+ format_currency(treenode.data.balance, treenode.data.currency)
|
||||||
+ '</span>');
|
+ '</span>');
|
||||||
}
|
}
|
||||||
@@ -142,7 +141,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
var data = $(link).data('node-data');
|
var data = $(link).data('node-data');
|
||||||
if(!data) return;
|
if(!data) return;
|
||||||
|
|
||||||
link.toolbar = $('<span class="tree-node-toolbar"></span>').insertAfter(link);
|
link.toolbar = $('<span class="tree-node-toolbar highlight"></span>').insertAfter(link);
|
||||||
|
|
||||||
var node_links = [];
|
var node_links = [];
|
||||||
// edit
|
// edit
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from webnotes import msgprint
|
|||||||
class LeaveDayBlockedError(webnotes.ValidationError): pass
|
class LeaveDayBlockedError(webnotes.ValidationError): pass
|
||||||
class OverlapError(webnotes.ValidationError): pass
|
class OverlapError(webnotes.ValidationError): pass
|
||||||
class InvalidLeaveApproverError(webnotes.ValidationError): pass
|
class InvalidLeaveApproverError(webnotes.ValidationError): pass
|
||||||
|
class LeaveApproverIdentityError(webnotes.ValidationError): pass
|
||||||
|
|
||||||
from webnotes.model.controller import DocListController
|
from webnotes.model.controller import DocListController
|
||||||
class DocType(DocListController):
|
class DocType(DocListController):
|
||||||
@@ -162,6 +163,10 @@ class DocType(DocListController):
|
|||||||
msgprint(get_fullname(self.doc.leave_approver) + ": " \
|
msgprint(get_fullname(self.doc.leave_approver) + ": " \
|
||||||
+ _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError)
|
+ _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError)
|
||||||
|
|
||||||
|
elif self.doc.docstatus==1 and len(leave_approvers) and self.doc.leave_approver != webnotes.session.user:
|
||||||
|
msgprint(_("Only the selected Leave Approver can submit this Leave Application"),
|
||||||
|
raise_exception=LeaveApproverIdentityError)
|
||||||
|
|
||||||
def notify_employee(self, status):
|
def notify_employee(self, status):
|
||||||
employee = webnotes.doc("Employee", self.doc.employee)
|
employee = webnotes.doc("Employee", self.doc.employee)
|
||||||
if not employee.user_id:
|
if not employee.user_id:
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
webnotes.set_user("test1@example.com")
|
webnotes.set_user("test1@example.com")
|
||||||
application.doc.status = "Approved"
|
application.doc.status = "Approved"
|
||||||
|
|
||||||
from webnotes.model.bean import BeanPermissionError
|
from hr.doctype.leave_application.leave_application import LeaveApproverIdentityError
|
||||||
self.assertRaises(BeanPermissionError, application.submit)
|
self.assertRaises(LeaveApproverIdentityError, application.submit)
|
||||||
|
|
||||||
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||||
"_T-Employee-0001")
|
"_T-Employee-0001")
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import webnotes
|
|||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
update_user_properties()
|
update_user_properties()
|
||||||
|
update_user_match()
|
||||||
update_permissions()
|
update_permissions()
|
||||||
|
remove_duplicate_restrictions()
|
||||||
webnotes.clear_cache()
|
webnotes.clear_cache()
|
||||||
|
|
||||||
def update_user_properties():
|
def update_user_properties():
|
||||||
@@ -23,6 +25,49 @@ def update_user_properties():
|
|||||||
where defkey=%s and
|
where defkey=%s and
|
||||||
parent not in ('__global', 'Control Panel')""", (df[0].options, d.defkey))
|
parent not in ('__global', 'Control Panel')""", (df[0].options, d.defkey))
|
||||||
|
|
||||||
|
def update_user_match():
|
||||||
|
import webnotes.defaults
|
||||||
|
doctype_matches = {}
|
||||||
|
for doctype, match in webnotes.conn.sql("""select parent, `match` from `tabDocPerm`
|
||||||
|
where `match` like %s""", "%:user"):
|
||||||
|
doctype_matches.setdefault(doctype, []).append(match)
|
||||||
|
|
||||||
|
for doctype, user_matches in doctype_matches.items():
|
||||||
|
|
||||||
|
# get permissions of this doctype
|
||||||
|
perms = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
|
||||||
|
where parent=%s and permlevel=0 and read=1""", doctype, as_dict=True)
|
||||||
|
|
||||||
|
# for each user with roles of this doctype, check if match condition applies
|
||||||
|
for profile in webnotes.conn.sql_list("""select name from `tabProfile`
|
||||||
|
where enabled=1 and user_type='System User'"""):
|
||||||
|
|
||||||
|
roles = webnotes.get_roles(profile)
|
||||||
|
|
||||||
|
user_match = False
|
||||||
|
for perm in perms:
|
||||||
|
if perm.role in roles and (perm.match and \
|
||||||
|
(perm.match.endswith(":user") or perm.match.endswith(":profile"))):
|
||||||
|
user_match = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not user_match:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# if match condition applies, restrict that user
|
||||||
|
# add that doc's restriction to that user
|
||||||
|
for match in user_matches:
|
||||||
|
for name in webnotes.conn.sql_list("""select name from `tab{doctype}`
|
||||||
|
where `{field}`=%s""".format(doctype=doctype, field=match.split(":")[0]), profile):
|
||||||
|
|
||||||
|
webnotes.defaults.add_default(doctype, name, profile, "Restriction")
|
||||||
|
|
||||||
|
def update_permissions():
|
||||||
|
# clear match conditions other than owner
|
||||||
|
webnotes.conn.sql("""update tabDocPerm set `match`=''
|
||||||
|
where ifnull(`match`,'') not in ('', 'owner')""")
|
||||||
|
|
||||||
|
def remove_duplicate_restrictions():
|
||||||
# remove duplicate restrictions (if they exist)
|
# remove duplicate restrictions (if they exist)
|
||||||
for d in webnotes.conn.sql("""select parent, defkey, defvalue,
|
for d in webnotes.conn.sql("""select parent, defkey, defvalue,
|
||||||
count(*) as cnt from tabDefaultValue
|
count(*) as cnt from tabDefaultValue
|
||||||
@@ -31,8 +76,3 @@ def update_user_properties():
|
|||||||
if d.cnt > 1:
|
if d.cnt > 1:
|
||||||
webnotes.conn.sql("""delete from tabDefaultValue where parent=%s, defkey=%s,
|
webnotes.conn.sql("""delete from tabDefaultValue where parent=%s, defkey=%s,
|
||||||
defvalue=%s limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1))
|
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')""")
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-10 16:34:30",
|
"creation": "2013-01-10 16:34:30",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-11-02 16:59:22",
|
"modified": "2013-12-11 11:14:32",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "harshada@webnotestech.com"
|
"owner": "harshada@webnotestech.com"
|
||||||
},
|
},
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"module": "Support",
|
"module": "Support",
|
||||||
"name": "__common__",
|
"name": "__common__",
|
||||||
"search_fields": "status,customer,customer_name,allocated_to,allocated_on, territory"
|
"search_fields": "status,customer,customer_name,territory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import webnotes, os, datetime
|
import webnotes, os, datetime
|
||||||
import webnotes.utils
|
import webnotes.utils
|
||||||
from webnotes.utils import random_string
|
from webnotes.utils import random_string, cstr
|
||||||
from webnotes.widgets import query_report
|
from webnotes.widgets import query_report
|
||||||
import random
|
import random
|
||||||
import json
|
import json
|
||||||
@@ -153,7 +153,7 @@ def run_stock(current_date):
|
|||||||
for po in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Receipt")]:
|
for po in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Receipt")]:
|
||||||
pr = webnotes.bean(make_purchase_receipt(po))
|
pr = webnotes.bean(make_purchase_receipt(po))
|
||||||
pr.doc.posting_date = current_date
|
pr.doc.posting_date = current_date
|
||||||
pr.doc.fiscal_year = current_date.year
|
pr.doc.fiscal_year = cstr(current_date.year)
|
||||||
pr.insert()
|
pr.insert()
|
||||||
try:
|
try:
|
||||||
pr.submit()
|
pr.submit()
|
||||||
@@ -169,7 +169,7 @@ def run_stock(current_date):
|
|||||||
for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]:
|
for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]:
|
||||||
dn = webnotes.bean(make_delivery_note(so))
|
dn = webnotes.bean(make_delivery_note(so))
|
||||||
dn.doc.posting_date = current_date
|
dn.doc.posting_date = current_date
|
||||||
dn.doc.fiscal_year = current_date.year
|
dn.doc.fiscal_year = cstr(current_date.year)
|
||||||
dn.insert()
|
dn.insert()
|
||||||
try:
|
try:
|
||||||
dn.submit()
|
dn.submit()
|
||||||
@@ -192,7 +192,7 @@ def run_purchase(current_date):
|
|||||||
mr = webnotes.new_bean("Material Request")
|
mr = webnotes.new_bean("Material Request")
|
||||||
mr.doc.material_request_type = "Purchase"
|
mr.doc.material_request_type = "Purchase"
|
||||||
mr.doc.transaction_date = current_date
|
mr.doc.transaction_date = current_date
|
||||||
mr.doc.fiscal_year = current_date.year
|
mr.doc.fiscal_year = cstr(current_date.year)
|
||||||
mr.doclist.append({
|
mr.doclist.append({
|
||||||
"doctype": "Material Request Item",
|
"doctype": "Material Request Item",
|
||||||
"parentfield": "indent_details",
|
"parentfield": "indent_details",
|
||||||
@@ -211,7 +211,7 @@ def run_purchase(current_date):
|
|||||||
if row[0] != "Total":
|
if row[0] != "Total":
|
||||||
sq = webnotes.bean(make_supplier_quotation(row[0]))
|
sq = webnotes.bean(make_supplier_quotation(row[0]))
|
||||||
sq.doc.transaction_date = current_date
|
sq.doc.transaction_date = current_date
|
||||||
sq.doc.fiscal_year = current_date.year
|
sq.doc.fiscal_year = cstr(current_date.year)
|
||||||
sq.insert()
|
sq.insert()
|
||||||
sq.submit()
|
sq.submit()
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
@@ -224,7 +224,7 @@ def run_purchase(current_date):
|
|||||||
if row[0] != "Total":
|
if row[0] != "Total":
|
||||||
po = webnotes.bean(make_purchase_order(row[0]))
|
po = webnotes.bean(make_purchase_order(row[0]))
|
||||||
po.doc.transaction_date = current_date
|
po.doc.transaction_date = current_date
|
||||||
po.doc.fiscal_year = current_date.year
|
po.doc.fiscal_year = cstr(current_date.year)
|
||||||
po.insert()
|
po.insert()
|
||||||
po.submit()
|
po.submit()
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
@@ -283,7 +283,7 @@ def make_stock_entry_from_pro(pro_id, purpose, current_date):
|
|||||||
try:
|
try:
|
||||||
st = webnotes.bean(make_stock_entry(pro_id, purpose))
|
st = webnotes.bean(make_stock_entry(pro_id, purpose))
|
||||||
st.doc.posting_date = current_date
|
st.doc.posting_date = current_date
|
||||||
st.doc.fiscal_year = current_date.year
|
st.doc.fiscal_year = cstr(current_date.year)
|
||||||
for d in st.doclist.get({"parentfield": "mtn_details"}):
|
for d in st.doclist.get({"parentfield": "mtn_details"}):
|
||||||
d.expense_account = "Stock Adjustment - " + company_abbr
|
d.expense_account = "Stock Adjustment - " + company_abbr
|
||||||
d.cost_center = "Main - " + company_abbr
|
d.cost_center = "Main - " + company_abbr
|
||||||
@@ -303,7 +303,7 @@ def make_quotation(current_date):
|
|||||||
"customer": get_random("Customer"),
|
"customer": get_random("Customer"),
|
||||||
"order_type": "Sales",
|
"order_type": "Sales",
|
||||||
"transaction_date": current_date,
|
"transaction_date": current_date,
|
||||||
"fiscal_year": current_date.year
|
"fiscal_year": cstr(current_date.year)
|
||||||
}])
|
}])
|
||||||
|
|
||||||
add_random_children(b, {
|
add_random_children(b, {
|
||||||
|
|||||||
Reference in New Issue
Block a user