mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
@@ -22,7 +22,12 @@
|
|||||||
|
|
||||||
pscript['onload_Accounts Browser'] = function(wrapper){
|
pscript['onload_Accounts Browser'] = function(wrapper){
|
||||||
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
|
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
|
||||||
wrapper.appframe.add_button('New Company', function() { newdoc('Company'); }, 'icon-plus');
|
|
||||||
|
if (wn.boot.profile.can_create.indexOf("Company") !== -1) {
|
||||||
|
wrapper.appframe.add_button('New Company', function() { newdoc('Company'); },
|
||||||
|
'icon-plus');
|
||||||
|
}
|
||||||
|
|
||||||
wrapper.appframe.add_button('Refresh', function() {
|
wrapper.appframe.add_button('Refresh', function() {
|
||||||
wrapper.$company_select.change();
|
wrapper.$company_select.change();
|
||||||
}, 'icon-refresh');
|
}, 'icon-refresh');
|
||||||
@@ -35,17 +40,6 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
})
|
})
|
||||||
.appendTo(wrapper.appframe.$w.find('.appframe-toolbar'));
|
.appendTo(wrapper.appframe.$w.find('.appframe-toolbar'));
|
||||||
|
|
||||||
// default company
|
|
||||||
if(sys_defaults.company) {
|
|
||||||
$('<option>')
|
|
||||||
.html(sys_defaults.company)
|
|
||||||
.attr('value', sys_defaults.company)
|
|
||||||
.appendTo(wrapper.$company_select);
|
|
||||||
|
|
||||||
wrapper.$company_select
|
|
||||||
.val(sys_defaults.company).change();
|
|
||||||
}
|
|
||||||
|
|
||||||
// load up companies
|
// load up companies
|
||||||
wn.call({
|
wn.call({
|
||||||
method:'accounts.page.accounts_browser.accounts_browser.get_companies',
|
method:'accounts.page.accounts_browser.accounts_browser.get_companies',
|
||||||
@@ -54,7 +48,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
$.each(r.message, function(i, v) {
|
$.each(r.message, function(i, v) {
|
||||||
$('<option>').html(v).attr('value', v).appendTo(wrapper.$company_select);
|
$('<option>').html(v).attr('value', v).appendTo(wrapper.$company_select);
|
||||||
});
|
});
|
||||||
wrapper.$company_select.val(sys_defaults.company || r[0]);
|
wrapper.$company_select.val(sys_defaults.company || r[0]).change();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,21 @@ from webnotes.utils import get_defaults, cstr
|
|||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_companies():
|
def get_companies():
|
||||||
return [r[0] for r in webnotes.conn.sql("""select name from tabCompany where docstatus!=2""")]
|
"""get a list of companies based on permission"""
|
||||||
|
|
||||||
|
# check if match permission exists
|
||||||
|
res = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
|
||||||
|
where parent='Account' and permlevel=0 and `read`=1""", as_dict=1)
|
||||||
|
|
||||||
|
match = any((r["match"] for r in res
|
||||||
|
if r["role"] in webnotes.user.roles and r["match"]=="company"))
|
||||||
|
|
||||||
|
# if match == company is specified and companies are specified in user defaults
|
||||||
|
if match and webnotes.user.get_defaults().get("company"):
|
||||||
|
return webnotes.user.get_defaults().get("company")
|
||||||
|
else:
|
||||||
|
return [r[0] for r in webnotes.conn.sql("""select name from tabCompany
|
||||||
|
where docstatus!=2""")]
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_children():
|
def get_children():
|
||||||
|
|||||||
Reference in New Issue
Block a user