[minor] user properties and leave application
This commit is contained in:
parent
83638b5f05
commit
bcf2422848
@ -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
|
||||
|
||||
pscript['onload_Accounts Browser'] = function(wrapper){
|
||||
console.log($(wrapper).html());
|
||||
wn.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
single_column: true
|
||||
@ -122,14 +121,14 @@ erpnext.AccountsChart = Class.extend({
|
||||
}
|
||||
|
||||
// bold
|
||||
$('.balance-bold').removeClass('balance-bold'); // deselect
|
||||
$(link).parent().find('.balance-area:first').addClass('balance-bold'); // select
|
||||
$('.bold').removeClass('bold'); // deselect
|
||||
$(link).parent().find('.balance-area:first').addClass('bold'); // select
|
||||
|
||||
},
|
||||
onrender: function(treenode) {
|
||||
if (ctype == 'Account' && treenode.data) {
|
||||
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)
|
||||
+ '</span>');
|
||||
}
|
||||
@ -142,7 +141,7 @@ erpnext.AccountsChart = Class.extend({
|
||||
var data = $(link).data('node-data');
|
||||
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 = [];
|
||||
// edit
|
||||
|
@ -12,6 +12,7 @@ from webnotes import msgprint
|
||||
class LeaveDayBlockedError(webnotes.ValidationError): pass
|
||||
class OverlapError(webnotes.ValidationError): pass
|
||||
class InvalidLeaveApproverError(webnotes.ValidationError): pass
|
||||
class LeaveApproverIdentityError(webnotes.ValidationError): pass
|
||||
|
||||
from webnotes.model.controller import DocListController
|
||||
class DocType(DocListController):
|
||||
@ -161,6 +162,10 @@ class DocType(DocListController):
|
||||
where parent=%s and role='Leave Approver'""", self.doc.leave_approver):
|
||||
msgprint(get_fullname(self.doc.leave_approver) + ": " \
|
||||
+ _("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):
|
||||
employee = webnotes.doc("Employee", self.doc.employee)
|
||||
|
@ -163,8 +163,8 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
webnotes.set_user("test1@example.com")
|
||||
application.doc.status = "Approved"
|
||||
|
||||
from webnotes.model.bean import BeanPermissionError
|
||||
self.assertRaises(BeanPermissionError, application.submit)
|
||||
from hr.doctype.leave_application.leave_application import LeaveApproverIdentityError
|
||||
self.assertRaises(LeaveApproverIdentityError, application.submit)
|
||||
|
||||
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||
"_T-Employee-0001")
|
||||
|
@ -6,7 +6,9 @@ import webnotes
|
||||
|
||||
def execute():
|
||||
update_user_properties()
|
||||
update_user_match()
|
||||
update_permissions()
|
||||
remove_duplicate_restrictions()
|
||||
webnotes.clear_cache()
|
||||
|
||||
def update_user_properties():
|
||||
@ -23,6 +25,49 @@ def update_user_properties():
|
||||
where defkey=%s and
|
||||
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)
|
||||
for d in webnotes.conn.sql("""select parent, defkey, defvalue,
|
||||
count(*) as cnt from tabDefaultValue
|
||||
@ -30,9 +75,4 @@ def update_user_properties():
|
||||
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')""")
|
||||
defvalue=%s limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1))
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:30",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-02 16:59:22",
|
||||
"modified": "2013-12-11 11:14:32",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "harshada@webnotestech.com"
|
||||
},
|
||||
@ -13,7 +13,7 @@
|
||||
"is_submittable": 0,
|
||||
"module": "Support",
|
||||
"name": "__common__",
|
||||
"search_fields": "status,customer,customer_name,allocated_to,allocated_on, territory"
|
||||
"search_fields": "status,customer,customer_name,territory"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import webnotes, os, datetime
|
||||
import webnotes.utils
|
||||
from webnotes.utils import random_string
|
||||
from webnotes.utils import random_string, cstr
|
||||
from webnotes.widgets import query_report
|
||||
import random
|
||||
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")]:
|
||||
pr = webnotes.bean(make_purchase_receipt(po))
|
||||
pr.doc.posting_date = current_date
|
||||
pr.doc.fiscal_year = current_date.year
|
||||
pr.doc.fiscal_year = cstr(current_date.year)
|
||||
pr.insert()
|
||||
try:
|
||||
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")]:
|
||||
dn = webnotes.bean(make_delivery_note(so))
|
||||
dn.doc.posting_date = current_date
|
||||
dn.doc.fiscal_year = current_date.year
|
||||
dn.doc.fiscal_year = cstr(current_date.year)
|
||||
dn.insert()
|
||||
try:
|
||||
dn.submit()
|
||||
@ -192,7 +192,7 @@ def run_purchase(current_date):
|
||||
mr = webnotes.new_bean("Material Request")
|
||||
mr.doc.material_request_type = "Purchase"
|
||||
mr.doc.transaction_date = current_date
|
||||
mr.doc.fiscal_year = current_date.year
|
||||
mr.doc.fiscal_year = cstr(current_date.year)
|
||||
mr.doclist.append({
|
||||
"doctype": "Material Request Item",
|
||||
"parentfield": "indent_details",
|
||||
@ -211,7 +211,7 @@ def run_purchase(current_date):
|
||||
if row[0] != "Total":
|
||||
sq = webnotes.bean(make_supplier_quotation(row[0]))
|
||||
sq.doc.transaction_date = current_date
|
||||
sq.doc.fiscal_year = current_date.year
|
||||
sq.doc.fiscal_year = cstr(current_date.year)
|
||||
sq.insert()
|
||||
sq.submit()
|
||||
webnotes.conn.commit()
|
||||
@ -224,7 +224,7 @@ def run_purchase(current_date):
|
||||
if row[0] != "Total":
|
||||
po = webnotes.bean(make_purchase_order(row[0]))
|
||||
po.doc.transaction_date = current_date
|
||||
po.doc.fiscal_year = current_date.year
|
||||
po.doc.fiscal_year = cstr(current_date.year)
|
||||
po.insert()
|
||||
po.submit()
|
||||
webnotes.conn.commit()
|
||||
@ -283,7 +283,7 @@ def make_stock_entry_from_pro(pro_id, purpose, current_date):
|
||||
try:
|
||||
st = webnotes.bean(make_stock_entry(pro_id, purpose))
|
||||
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"}):
|
||||
d.expense_account = "Stock Adjustment - " + company_abbr
|
||||
d.cost_center = "Main - " + company_abbr
|
||||
@ -303,7 +303,7 @@ def make_quotation(current_date):
|
||||
"customer": get_random("Customer"),
|
||||
"order_type": "Sales",
|
||||
"transaction_date": current_date,
|
||||
"fiscal_year": current_date.year
|
||||
"fiscal_year": cstr(current_date.year)
|
||||
}])
|
||||
|
||||
add_random_children(b, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user