mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
fixed conflict while merging
This commit is contained in:
@@ -66,7 +66,7 @@ def make_feed(feedtype, doctype, name, owner, subject, color):
|
|||||||
|
|
||||||
def update_feed(doc, method=None):
|
def update_feed(doc, method=None):
|
||||||
"adds a new feed"
|
"adds a new feed"
|
||||||
if method=='on_update':
|
if method in ['on_update', 'on_submit']:
|
||||||
subject, color = feed_dict.get(doc.doctype, [None, None])
|
subject, color = feed_dict.get(doc.doctype, [None, None])
|
||||||
if subject:
|
if subject:
|
||||||
make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.fields, color)
|
make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.fields, color)
|
||||||
|
|||||||
20
erpnext/patches/jan_mar_2012/fix_packing_slip.py
Normal file
20
erpnext/patches/jan_mar_2012/fix_packing_slip.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
def execute():
|
||||||
|
"""
|
||||||
|
* Change DN to PS mapper
|
||||||
|
+ Set Ref doc should be submitted to 0
|
||||||
|
+ Set validation logic of DN PS Table mapper record to docstatus=0
|
||||||
|
"""
|
||||||
|
import webnotes
|
||||||
|
webnotes.conn.sql("""\
|
||||||
|
UPDATE `tabDocType Mapper`
|
||||||
|
SET ref_doc_submitted=0
|
||||||
|
WHERE name='Delivery Note-Packing Slip'""")
|
||||||
|
|
||||||
|
webnotes.conn.sql("""\
|
||||||
|
UPDATE `tabTable Mapper Detail`
|
||||||
|
SET validation_logic='docstatus=0'
|
||||||
|
WHERE parent='Delivery Note-Packing Slip'
|
||||||
|
AND docstatus=0
|
||||||
|
AND from_table='Delivery Note'
|
||||||
|
AND to_table='Packing Slip'""")
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ def execute():
|
|||||||
from webnotes.utils import archive
|
from webnotes.utils import archive
|
||||||
arc_tables = webnotes.conn.sql('show tables like "arc%"')
|
arc_tables = webnotes.conn.sql('show tables like "arc%"')
|
||||||
try:
|
try:
|
||||||
|
webnotes.conn.auto_commit_on_many_writes = 1
|
||||||
for tab in arc_tables:
|
for tab in arc_tables:
|
||||||
tab = tab[0]
|
tab = tab[0]
|
||||||
dt = tab[3:]
|
dt = tab[3:]
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import patches.jan_mar_2012.website.cleanups
|
|||||||
import patches.jan_mar_2012.website.domain_list
|
import patches.jan_mar_2012.website.domain_list
|
||||||
import patches.jan_mar_2012.website.file_data_rename
|
import patches.jan_mar_2012.website.file_data_rename
|
||||||
import patches.jan_mar_2012.website.analytics
|
import patches.jan_mar_2012.website.analytics
|
||||||
|
import patches.jan_mar_2012.website.allow_product_delete
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
@@ -15,3 +16,4 @@ def execute():
|
|||||||
patches.jan_mar_2012.website.domain_list.execute()
|
patches.jan_mar_2012.website.domain_list.execute()
|
||||||
patches.jan_mar_2012.website.file_data_rename.execute()
|
patches.jan_mar_2012.website.file_data_rename.execute()
|
||||||
patches.jan_mar_2012.website.analytics.execute()
|
patches.jan_mar_2012.website.analytics.execute()
|
||||||
|
patches.jan_mar_2012.website.allow_product_delete.execute()
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
def execute():
|
||||||
|
"""
|
||||||
|
Allow deletion of products
|
||||||
|
"""
|
||||||
|
import webnotes
|
||||||
|
webnotes.conn.sql("""UPDATE `tabDocPerm` SET cancel=1
|
||||||
|
WHERE parent='Product' AND role='Website Manager'
|
||||||
|
AND permlevel=0""")
|
||||||
@@ -23,17 +23,23 @@ def execute():
|
|||||||
txt = get_file_id(txt)
|
txt = get_file_id(txt)
|
||||||
|
|
||||||
webnotes.conn.sql("""update `tab%s` set %s=%s where name=%s""" % \
|
webnotes.conn.sql("""update `tab%s` set %s=%s where name=%s""" % \
|
||||||
(table[0], table[1], '%s', '%s'), (txt, item[0]), debug=1)
|
(table[0], table[1], '%s', '%s'), (txt, item[0]))
|
||||||
|
|
||||||
# control panel, client name
|
# control panel, client name
|
||||||
txt = webnotes.conn.get_value('Control Panel',None,'client_name')
|
txt = webnotes.conn.get_value('Control Panel',None,'client_name')
|
||||||
txt = get_file_id(txt)
|
if txt:
|
||||||
webnotes.conn.set_value('Control Panel', None, 'client_name', txt.replace('index.cgi?cmd=get_file&fname=', 'files/'))
|
txt = get_file_id(txt)
|
||||||
|
webnotes.conn.set_value('Control Panel', None, 'client_name', txt.replace('index.cgi?cmd=get_file&fname=', 'files/'))
|
||||||
|
|
||||||
def get_file_id(txt):
|
def get_file_id(txt):
|
||||||
"""old file links may be from fileid or filename"""
|
"""old file links may be from fileid or filename"""
|
||||||
import re
|
import re
|
||||||
match = re.search('files/([^"\']*)', txt)
|
match = re.search('files/([^"\']*)', txt)
|
||||||
|
|
||||||
|
if not match:
|
||||||
|
print txt
|
||||||
|
return txt
|
||||||
|
|
||||||
fname = match.groups()[0]
|
fname = match.groups()[0]
|
||||||
if not fname.startswith('FileData'):
|
if not fname.startswith('FileData'):
|
||||||
fid = webnotes.conn.sql("""select name from `tabFile Data`
|
fid = webnotes.conn.sql("""select name from `tabFile Data`
|
||||||
|
|||||||
@@ -99,5 +99,10 @@ patch_list = [
|
|||||||
'patch_module': 'patches.jan_mar_2012',
|
'patch_module': 'patches.jan_mar_2012',
|
||||||
'patch_file': 'reload_item',
|
'patch_file': 'reload_item',
|
||||||
'description': 'reload item'
|
'description': 'reload item'
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.jan_mar_2012',
|
||||||
|
'patch_file': 'fix_packing_slip',
|
||||||
|
'description': 'Update Mapper Delivery Note-Packing Slip'
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
<div class="layout_wrapper">
|
<div class="layout_wrapper">
|
||||||
<div id="pe_header"></div>
|
<div id="pe_header"></div>
|
||||||
<div id="perm_engine_div" style="margin: 16px;"></div>
|
<div id="perm_engine_div" style="margin: 16px;"></div>
|
||||||
|
<div id="submittable_warning" class='help-box' style='display: None'>
|
||||||
|
One of the Roles has <b>Submit</b> permission.
|
||||||
|
You will have to <b>Cancel</b> and then <b>Amend</b> a submitted Document for making changes.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,397 +1,421 @@
|
|||||||
pscript['onload_Permission Engine'] = function() {
|
pscript['onload_Permission Engine'] = function() {
|
||||||
// header and toolbar
|
// header and toolbar
|
||||||
var h = new PageHeader('pe_header','Permissions Manager','Set specific permissions for Roles')
|
var h = new PageHeader('pe_header','Permissions Manager','Set specific permissions for Roles')
|
||||||
|
|
||||||
if(!pscript.perm_engine) pscript.perm_engine = new pscript.PermEngine();
|
if(!pscript.perm_engine) pscript.perm_engine = new pscript.PermEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pscript.PermEngine = function() {
|
pscript.PermEngine = function() {
|
||||||
// create UI elements
|
// create UI elements
|
||||||
this.wrapper = $i('perm_engine_div');
|
this.wrapper = $i('perm_engine_div');
|
||||||
|
|
||||||
this.head = $a(this.wrapper, 'div');
|
this.head = $a(this.wrapper, 'div');
|
||||||
this.body = $a(this.wrapper, 'div');
|
this.body = $a(this.wrapper, 'div');
|
||||||
this.footer = $a(this.wrapper, 'div');
|
this.footer = $a(this.wrapper, 'div');
|
||||||
|
|
||||||
var lab = $a(this.body,'div', '', {backgroundColor:'#FFD', padding:'8px', margin:'16px 0px'});
|
var lab = $a(this.body,'div', '', {backgroundColor:'#FFD', padding:'8px', margin:'16px 0px'});
|
||||||
lab.innerHTML = 'Please select the item for which you want to set permissions';
|
lab.innerHTML = 'Please select the item for which you want to set permissions';
|
||||||
|
|
||||||
this.make_head();
|
this.make_head();
|
||||||
this.load_options();
|
this.load_options();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make Head
|
// Make Head
|
||||||
// -------------
|
// -------------
|
||||||
pscript.PermEngine.prototype.make_head = function() {
|
pscript.PermEngine.prototype.make_head = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
var make_select = function(label) {
|
var make_select = function(label) {
|
||||||
var w = $a(me.head, 'div', '', {margin:'8px 0px'});
|
var w = $a(me.head, 'div', '', {margin:'8px 0px'});
|
||||||
var t = make_table(w,1,2,'300px',['50%','50%']);
|
var t = make_table(w,1,2,'300px',['50%','50%']);
|
||||||
$td(t,0,0).innerHTML = label;
|
$td(t,0,0).innerHTML = label;
|
||||||
var s = $a($td(t,0,1),'select','',{width:'140px'});
|
var s = $a($td(t,0,1),'select','',{width:'140px'});
|
||||||
s.wrapper = w;
|
s.wrapper = w;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
var make_button = function(label, parent, green) {
|
var make_button = function(label, parent, green) {
|
||||||
return $btn(parent, label, null, {margin:'8px 0px', display:'none'}, (green ? 'green' : null));
|
return $btn(parent, label, null, {margin:'8px 0px', display:'none'}, (green ? 'green' : null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set Permissions for
|
// Set Permissions for
|
||||||
this.type_select = make_select('Set Permissions For');
|
this.type_select = make_select('Set Permissions For');
|
||||||
this.type_select.onchange = function() {
|
this.type_select.onchange = function() {
|
||||||
me.get_permissions();
|
me.get_permissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Button
|
// Update Button
|
||||||
this.add_button = make_button('+ Add A New Rule', this.head, 0);
|
this.add_button = make_button('+ Add A New Rule', this.head, 0);
|
||||||
this.add_button.onclick = function() {
|
this.add_button.onclick = function() {
|
||||||
me.add_permission();
|
me.add_permission();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Button
|
// Update Button
|
||||||
this.update_button = make_button('Update', this.footer, 1);
|
this.update_button = make_button('Update', this.footer, 1);
|
||||||
this.update_button.onclick = function() {
|
this.update_button.onclick = function() {
|
||||||
me.update_permissions();
|
me.update_permissions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Permissions
|
// Add Permissions
|
||||||
// -----------------
|
// -----------------
|
||||||
pscript.PermEngine.prototype.add_permission = function() {
|
pscript.PermEngine.prototype.add_permission = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(!this.add_permission_dialog) {
|
if(!this.add_permission_dialog) {
|
||||||
|
|
||||||
// dialog
|
// dialog
|
||||||
var d = new Dialog(400,400,'Add Permission');
|
var d = new Dialog(400,400,'Add Permission');
|
||||||
d.make_body([['Select','Role'],['Select','Level'],['Button','Add']])
|
d.make_body([['Select','Role'],['Select','Level'],['Button','Add']])
|
||||||
|
|
||||||
add_sel_options(d.widgets['Role'], this.roles, '');
|
add_sel_options(d.widgets['Role'], this.roles, '');
|
||||||
add_sel_options(d.widgets['Level'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
|
add_sel_options(d.widgets['Level'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
|
||||||
|
|
||||||
// add
|
// add
|
||||||
d.widgets['Add'].onclick = function() {
|
d.widgets['Add'].onclick = function() {
|
||||||
if(!sel_val(d.widgets['Role'])) {
|
if(!sel_val(d.widgets['Role'])) {
|
||||||
msgprint('Please select Role'); return;
|
msgprint('Please select Role'); return;
|
||||||
}
|
}
|
||||||
var callback = function(r, rt) {
|
var callback = function(r, rt) {
|
||||||
// reload
|
// reload
|
||||||
me.get_permissions();
|
me.get_permissions();
|
||||||
d.hide();
|
d.hide();
|
||||||
}
|
}
|
||||||
$c_obj('Permission Control','add_permission',JSON.stringify([sel_val(me.type_select), sel_val(d.widgets['Role']), sel_val(d.widgets['Level'])]), callback);
|
$c_obj('Permission Control','add_permission',JSON.stringify([sel_val(me.type_select), sel_val(d.widgets['Role']), sel_val(d.widgets['Level'])]), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.add_permission_dialog = d;
|
this.add_permission_dialog = d;
|
||||||
}
|
}
|
||||||
this.add_permission_dialog.show();
|
this.add_permission_dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Hide Fields
|
// Hide Fields
|
||||||
// -----------------
|
// -----------------
|
||||||
pscript.PermEngine.prototype.hide_fields = function() {
|
pscript.PermEngine.prototype.hide_fields = function() {
|
||||||
$dh(this.role_select.wrapper);
|
$dh(this.role_select.wrapper);
|
||||||
this.type_select.disabled = false;
|
this.type_select.disabled = false;
|
||||||
this.body.innerHTML = '';
|
this.body.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load Roles And Modules
|
// Load Roles And Modules
|
||||||
// -----------------------
|
// -----------------------
|
||||||
pscript.PermEngine.prototype.load_options = function() {
|
pscript.PermEngine.prototype.load_options = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
$dh(me.update_button);
|
$dh(me.update_button);
|
||||||
$dh(me.add_button);
|
$dh(me.add_button);
|
||||||
|
|
||||||
$c_obj('Permission Control','get_doctype_list','', function(r,rt) {
|
$c_obj('Permission Control','get_doctype_list','', function(r,rt) {
|
||||||
me.roles = r.message.roles;
|
me.roles = r.message.roles;
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
empty_select(me.type_select);
|
empty_select(me.type_select);
|
||||||
add_sel_options(me.type_select,add_lists([''], r.message.doctypes));
|
add_sel_options(me.type_select,add_lists([''], r.message.doctypes));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get DocType and Permissions related to module
|
// Get DocType and Permissions related to module
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
pscript.PermEngine.prototype.get_permissions = function() {
|
pscript.PermEngine.prototype.get_permissions = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
if(!sel_val(me.type_select)) {
|
if(!sel_val(me.type_select)) {
|
||||||
msgprint('Please select a type first!'); return;
|
msgprint('Please select a type first!'); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$c_obj('Permission Control','get_permissions',sel_val(me.type_select), function(r,rt) {
|
$c_obj('Permission Control','get_permissions',sel_val(me.type_select), function(r,rt) {
|
||||||
// Get permissions
|
// Get permissions
|
||||||
if(r.message.perms.length)me.get_results(r.message);
|
if(r.message.perms.length) {
|
||||||
else me.body.innerHTML = '<div style = "color : red; margin:8px 0px;">No Records Found</div>'
|
me.get_results(r.message);
|
||||||
});
|
}
|
||||||
|
else me.body.innerHTML = '<div style = "color : red; margin:8px 0px;">No Records Found</div>'
|
||||||
|
pscript.show_submittable();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Results
|
// Get Results
|
||||||
// ------------------
|
// ------------------
|
||||||
pscript.PermEngine.prototype.get_results = function(r){
|
pscript.PermEngine.prototype.get_results = function(r){
|
||||||
var perms = r.perms;
|
var perms = r.perms;
|
||||||
var me = this;
|
var me = this;
|
||||||
var doctype = sel_val(me.type_select);
|
var doctype = sel_val(me.type_select);
|
||||||
|
|
||||||
// show update button
|
// show update button
|
||||||
$ds(me.update_button);
|
$ds(me.update_button);
|
||||||
$ds(me.add_button);
|
$ds(me.add_button);
|
||||||
|
|
||||||
this.body.innerHTML = ''
|
this.body.innerHTML = ''
|
||||||
pscript.all_checkboxes = [];
|
pscript.all_checkboxes = [];
|
||||||
pscript.all_matches = [];
|
pscript.all_matches = [];
|
||||||
|
|
||||||
var head = $a(this.body, 'h3'); head.innerHTML = 'Rules for ' + doctype;
|
var head = $a(this.body, 'h3'); head.innerHTML = 'Rules for ' + doctype;
|
||||||
var permt = make_table(me.body, perms.length+1,9,'80%',[],{border:'1px solid #AAA', padding:'3px', verticalAlign:'middle', height:'30px'});
|
var permt = make_table(me.body, perms.length+1,9,'80%',[],{border:'1px solid #AAA', padding:'3px', verticalAlign:'middle', height:'30px'});
|
||||||
|
|
||||||
// Create Grid for particular DocType
|
// Create Grid for particular DocType
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
// Columns
|
// Columns
|
||||||
var col_labels = ['Role','Level','Read','Write','Create','Submit','Cancel','Amend','Restrict By']
|
var col_labels = ['Role','Level','Read','Write','Create','Submit','Cancel','Amend','Restrict By']
|
||||||
for(var n = 0; n < col_labels.length; n++){
|
for(var n = 0; n < col_labels.length; n++){
|
||||||
$y($td(permt,0,n), {backgroundColor:'#DDD', width:(n==0?'30%':(n==8?'21%':'7%'))})
|
$y($td(permt,0,n), {backgroundColor:'#DDD', width:(n==0?'30%':(n==8?'21%':'7%'))})
|
||||||
$td(permt,0,n).innerHTML = col_labels[n];
|
$td(permt,0,n).innerHTML = col_labels[n];
|
||||||
$td(permt,0,n).fieldname = col_labels[n].toLowerCase();
|
$td(permt,0,n).fieldname = col_labels[n].toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rows for Column Level / Role
|
// Rows for Column Level / Role
|
||||||
for(var j = 0; j < perms.length; j++){
|
for(var j = 0; j < perms.length; j++){
|
||||||
var plevel = $a($td(permt,j+1,1), 'span', 'link_type');
|
var plevel = $a($td(permt,j+1,1), 'span', 'link_type');
|
||||||
plevel.innerHTML = perms[j].permlevel;
|
plevel.innerHTML = perms[j].permlevel;
|
||||||
plevel.doctype = doctype;
|
plevel.doctype = doctype;
|
||||||
plevel.value = perms[j].permlevel;
|
plevel.value = perms[j].permlevel;
|
||||||
plevel.onclick = function() {me.get_fields(this.doctype, this.value)}
|
plevel.onclick = function() {me.get_fields(this.doctype, this.value)}
|
||||||
|
|
||||||
// role
|
// role
|
||||||
$td(permt,j+1,0).innerHTML = perms[j].role;
|
$td(permt,j+1,0).innerHTML = perms[j].role;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get values
|
// Get values
|
||||||
for(var l = 0; l < perms.length; l++){
|
for(var l = 0; l < perms.length; l++){
|
||||||
for(var m = 0; m < 6; m++){ // (read,write,create,submit,cancel,amend)
|
for(var m = 0; m < 6; m++){ // (read,write,create,submit,cancel,amend)
|
||||||
var chk = $a_input($td(permt,l+1,m+2), 'checkbox');
|
var chk = $a_input($td(permt,l+1,m+2), 'checkbox');
|
||||||
var val = perms[l][$td(permt,0,m+2).fieldname];
|
var val = perms[l][$td(permt,0,m+2).fieldname];
|
||||||
if(val == 1) chk.checked = 1;
|
if(val == 1) chk.checked = 1;
|
||||||
else chk.checked = 0;
|
else chk.checked = 0;
|
||||||
chk.doctype = doctype;
|
|
||||||
chk.permlevel = perms[l].permlevel; chk.perm_type = col_labels[m+2].toLowerCase(); chk.role = perms[l].role;
|
|
||||||
pscript.all_checkboxes.push(chk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add selects for match
|
if(m==3) { chk.onclick = pscript.show_submittable }
|
||||||
me.add_match_select(r, perms, permt, doctype);
|
|
||||||
|
chk.doctype = doctype;
|
||||||
|
chk.permlevel = perms[l].permlevel; chk.perm_type = col_labels[m+2].toLowerCase(); chk.role = perms[l].role;
|
||||||
|
pscript.all_checkboxes.push(chk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add selects for match
|
||||||
|
me.add_match_select(r, perms, permt, doctype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show submittable warning
|
||||||
|
pscript.show_submittable = function() {
|
||||||
|
var submittable = 0;
|
||||||
|
for(i in pscript.all_checkboxes) {
|
||||||
|
c = pscript.all_checkboxes[i];
|
||||||
|
if(c.perm_type=='submit' && c.checked) {
|
||||||
|
submittable = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(submittable) {
|
||||||
|
$('#submittable_warning').toggle(true);
|
||||||
|
} else {
|
||||||
|
$('#submittable_warning').toggle(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// render selects for match
|
// render selects for match
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
pscript.PermEngine.prototype.add_match_select = function(r, perms, permt, doctype) {
|
pscript.PermEngine.prototype.add_match_select = function(r, perms, permt, doctype) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
// add select for match
|
// add select for match
|
||||||
for(var i=0; i<perms.length; i++) {
|
for(var i=0; i<perms.length; i++) {
|
||||||
if(perms[i].permlevel==0) {
|
if(perms[i].permlevel==0) {
|
||||||
// select
|
// select
|
||||||
var sel = $a($td(permt,i+1,8),'select','',{width:'100%'});
|
var sel = $a($td(permt,i+1,8),'select','',{width:'100%'});
|
||||||
add_sel_options(sel, r.fields);
|
add_sel_options(sel, r.fields);
|
||||||
sel.details = perms[i]; sel.details.parent = doctype;
|
sel.details = perms[i]; sel.details.parent = doctype;
|
||||||
sel.onchange = function() {
|
sel.onchange = function() {
|
||||||
if(sel_val(this) && sel_val(this)!='owner') $ds(this.div);
|
if(sel_val(this) && sel_val(this)!='owner') $ds(this.div);
|
||||||
else $dh(this.div); }
|
else $dh(this.div); }
|
||||||
|
|
||||||
// link
|
// link
|
||||||
var div = $a($td(permt,i+1,8),'div','link_type',{marginTop: '2px', fontSize:'10px', display:'none'});
|
var div = $a($td(permt,i+1,8),'div','link_type',{marginTop: '2px', fontSize:'10px', display:'none'});
|
||||||
div.onclick = function() { this.details.match = sel_val(this.sel); me.show_match_dialog(this.details); }
|
div.onclick = function() { this.details.match = sel_val(this.sel); me.show_match_dialog(this.details); }
|
||||||
div.innerHTML = 'Set Users / Roles';
|
div.innerHTML = 'Set Users / Roles';
|
||||||
div.details = perms[i];
|
div.details = perms[i];
|
||||||
sel.div = div; div.sel = sel;
|
sel.div = div; div.sel = sel;
|
||||||
|
|
||||||
// set the value
|
// set the value
|
||||||
if(perms[i].match) { sel.value = perms[i].match; $ds(div); }
|
if(perms[i].match) { sel.value = perms[i].match; $ds(div); }
|
||||||
|
|
||||||
pscript.all_matches.push(sel);
|
pscript.all_matches.push(sel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// match users Dialog
|
// match users Dialog
|
||||||
// =======================================================
|
// =======================================================
|
||||||
|
|
||||||
pscript.PermEngine.prototype.show_match_dialog=function(details) {
|
pscript.PermEngine.prototype.show_match_dialog=function(details) {
|
||||||
if(!this.match_defaults_dialog) {
|
if(!this.match_defaults_dialog) {
|
||||||
var d = new Dialog(750, 500, 'Permission Applies To');
|
var d = new Dialog(750, 500, 'Permission Applies To');
|
||||||
d.make_body([['HTML','Body']]);
|
d.make_body([['HTML','Body']]);
|
||||||
var w = d.widgets['Body'];
|
var w = d.widgets['Body'];
|
||||||
$y(w,{height:'350px', overflow:'auto'});
|
$y(w,{height:'350px', overflow:'auto'});
|
||||||
this.match_defaults_dialog = d;
|
this.match_defaults_dialog = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dialog
|
// dialog
|
||||||
this.match_defaults_dialog.show();
|
this.match_defaults_dialog.show();
|
||||||
|
|
||||||
// render the rules
|
// render the rules
|
||||||
var me = this;
|
var me = this;
|
||||||
var callback = function(r,rt) {
|
var callback = function(r,rt) {
|
||||||
me.render_match_dialog(r, details);
|
me.render_match_dialog(r, details);
|
||||||
}
|
}
|
||||||
// load the rules
|
// load the rules
|
||||||
$c_obj('Permission Control','get_defaults', details.match + '~~~' + (this.profiles ? 'No' : 'Yes'), callback);
|
$c_obj('Permission Control','get_defaults', details.match + '~~~' + (this.profiles ? 'No' : 'Yes'), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
pscript.PermEngine.prototype.render_match_dialog=function(r, details) {
|
pscript.PermEngine.prototype.render_match_dialog=function(r, details) {
|
||||||
var d = this.match_defaults_dialog;
|
var d = this.match_defaults_dialog;
|
||||||
var w = d.widgets['Body'];
|
var w = d.widgets['Body'];
|
||||||
w.innerHTML = '<div style="background-color:#FFD; padding: 4px; color: #440; margin-bottom:16px">Please Note: Any action will also affect other permissions with similar rules!</div>'
|
w.innerHTML = '<div style="background-color:#FFD; padding: 4px; color: #440; margin-bottom:16px">Please Note: Any action will also affect other permissions with similar rules!</div>'
|
||||||
|
|
||||||
// header
|
// header
|
||||||
var t=make_table($a(w,'div','',{borderBottom:'1px solid #AAA'}),1,3,'90%',['40%','40%','20%'],{fontWeight:'bold', padding:'3px', fontSize:'14px'});
|
var t=make_table($a(w,'div','',{borderBottom:'1px solid #AAA'}),1,3,'90%',['40%','40%','20%'],{fontWeight:'bold', padding:'3px', fontSize:'14px'});
|
||||||
$td(t,0,0).innerHTML = 'Who?'; $td(t,0,1).innerHTML = 'Is allowed if '+details.match+' equals';
|
$td(t,0,0).innerHTML = 'Who?'; $td(t,0,1).innerHTML = 'Is allowed if '+details.match+' equals';
|
||||||
|
|
||||||
// existing defaults
|
// existing defaults
|
||||||
var dl = r.message.dl; this.options = r.message.ol;
|
var dl = r.message.dl; this.options = r.message.ol;
|
||||||
if(!this.profiles) {
|
if(!this.profiles) {
|
||||||
this.profiles = r.message.pl;
|
this.profiles = r.message.pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i=0; i<dl.length; i++) {
|
for(var i=0; i<dl.length; i++) {
|
||||||
new MatchDefaultValue(this, w, dl[i], details.match);
|
new MatchDefaultValue(this, w, dl[i], details.match);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.add_new_match_row(details.match);
|
this.add_new_match_row(details.match);
|
||||||
}
|
}
|
||||||
|
|
||||||
pscript.PermEngine.prototype.add_new_match_row = function(fieldname) {
|
pscript.PermEngine.prototype.add_new_match_row = function(fieldname) {
|
||||||
// add new default
|
// add new default
|
||||||
new MatchDefaultValue(this, this.match_defaults_dialog.widgets['Body'], null, fieldname, 1);
|
new MatchDefaultValue(this, this.match_defaults_dialog.widgets['Body'], null, fieldname, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
MatchDefaultValue = function(pe, parent, details, fieldname, editable) {
|
MatchDefaultValue = function(pe, parent, details, fieldname, editable) {
|
||||||
this.pe = pe;
|
this.pe = pe;
|
||||||
this.wrapper = $a(parent, 'div', '', {margin:'4px'});
|
this.wrapper = $a(parent, 'div', '', {margin:'4px'});
|
||||||
this.clear();
|
this.clear();
|
||||||
this.details = details;
|
this.details = details;
|
||||||
this.fieldname = fieldname;
|
this.fieldname = fieldname;
|
||||||
this.render(editable);
|
this.render(editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
MatchDefaultValue.prototype.clear = function() {
|
MatchDefaultValue.prototype.clear = function() {
|
||||||
this.wrapper.innerHTML = '';
|
this.wrapper.innerHTML = '';
|
||||||
this.tab = make_table(this.wrapper, 1, 3, '90%', ['40%','40%','20%'], {verticalAlign:'middle', padding:'3px'});
|
this.tab = make_table(this.wrapper, 1, 3, '90%', ['40%','40%','20%'], {verticalAlign:'middle', padding:'3px'});
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
MatchDefaultValue.prototype.render = function(editable) {
|
MatchDefaultValue.prototype.render = function(editable) {
|
||||||
|
|
||||||
if(editable) {
|
if(editable) {
|
||||||
this.render_editable();
|
this.render_editable();
|
||||||
} else {
|
} else {
|
||||||
this.render_static();
|
this.render_static();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
MatchDefaultValue.prototype.render_editable = function() {
|
MatchDefaultValue.prototype.render_editable = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
// profile or role
|
// profile or role
|
||||||
this.profile_or_role = $a($td(this.tab,0,0), 'select', '', {width:'60px', marginRight:'8px'});
|
this.profile_or_role = $a($td(this.tab,0,0), 'select', '', {width:'60px', marginRight:'8px'});
|
||||||
add_sel_options(this.profile_or_role,['Profile', 'Role'], 'Profile');
|
add_sel_options(this.profile_or_role,['Profile', 'Role'], 'Profile');
|
||||||
this.profile_or_role.onchange = function() {
|
this.profile_or_role.onchange = function() {
|
||||||
if(sel_val(this)=='Profile') { $di(me.profile_sel); $dh(me.role_sel); }
|
if(sel_val(this)=='Profile') { $di(me.profile_sel); $dh(me.role_sel); }
|
||||||
else { $dh(me.profile_sel); $di(me.role_sel); }
|
else { $dh(me.profile_sel); $di(me.role_sel); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// role sel
|
// role sel
|
||||||
this.role_sel = $a($td(this.tab,0,0), 'select', '', {width:'100px',display:'none'});
|
this.role_sel = $a($td(this.tab,0,0), 'select', '', {width:'100px',display:'none'});
|
||||||
add_sel_options(this.role_sel,this.pe.roles);
|
add_sel_options(this.role_sel,this.pe.roles);
|
||||||
|
|
||||||
// profile sel
|
// profile sel
|
||||||
this.profile_sel = $a($td(this.tab,0,0), 'select', '', {width:'100px'});
|
this.profile_sel = $a($td(this.tab,0,0), 'select', '', {width:'100px'});
|
||||||
add_sel_options(this.profile_sel,this.pe.profiles);
|
add_sel_options(this.profile_sel,this.pe.profiles);
|
||||||
|
|
||||||
// options sel
|
// options sel
|
||||||
this.options_sel = $a($td(this.tab,0,1), 'select', '', {width:'120px'});
|
this.options_sel = $a($td(this.tab,0,1), 'select', '', {width:'120px'});
|
||||||
add_sel_options(this.options_sel,this.pe.options);
|
add_sel_options(this.options_sel,this.pe.options);
|
||||||
|
|
||||||
// add
|
// add
|
||||||
var span = $a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});
|
var span = $a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});
|
||||||
span.innerHTML = 'Add'
|
span.innerHTML = 'Add'
|
||||||
span.onclick = function() { me.save(); }
|
span.onclick = function() { me.save(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
MatchDefaultValue.prototype.render_static = function() {
|
MatchDefaultValue.prototype.render_static = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
$td(this.tab,0,0).innerHTML = this.details.parenttype;
|
$td(this.tab,0,0).innerHTML = this.details.parenttype;
|
||||||
$td(this.tab,0,0).innerHTML += ' ' + this.details.parent;
|
$td(this.tab,0,0).innerHTML += ' ' + this.details.parent;
|
||||||
$td(this.tab,0,1).innerHTML = this.details.defvalue;
|
$td(this.tab,0,1).innerHTML = this.details.defvalue;
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
var span = $a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});
|
var span = $a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});
|
||||||
span.innerHTML = 'Cancel'
|
span.innerHTML = 'Cancel'
|
||||||
span.onclick = function() { me.delete_def(); }
|
span.onclick = function() { me.delete_def(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
MatchDefaultValue.prototype.delete_def = function() {
|
MatchDefaultValue.prototype.delete_def = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.wrapper.innerHTML = '<div style="color: #888; padding: 3px;">Deleting...</div>';
|
this.wrapper.innerHTML = '<div style="color: #888; padding: 3px;">Deleting...</div>';
|
||||||
var callback = function(r,rt) {
|
var callback = function(r,rt) {
|
||||||
$dh(me.wrapper);
|
$dh(me.wrapper);
|
||||||
if(r.exc) msgprint('There were errors!')
|
if(r.exc) msgprint('There were errors!')
|
||||||
}
|
}
|
||||||
$c_obj('Permission Control','delete_default'
|
$c_obj('Permission Control','delete_default'
|
||||||
,[this.details.parent, this.fieldname, this.details.defvalue].join('~~~')
|
,[this.details.parent, this.fieldname, this.details.defvalue].join('~~~')
|
||||||
,callback)
|
,callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
MatchDefaultValue.prototype.save = function() {
|
MatchDefaultValue.prototype.save = function() {
|
||||||
var me= this;
|
var me= this;
|
||||||
|
|
||||||
var callback = function(r,rt) {
|
var callback = function(r,rt) {
|
||||||
me.details = r.message;
|
me.details = r.message;
|
||||||
me.clear();
|
me.clear();
|
||||||
me.render();
|
me.render();
|
||||||
me.pe.add_new_match_row(me.fieldname);
|
me.pe.add_new_match_row(me.fieldname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// values
|
// values
|
||||||
if(sel_val(this.profile_or_role)=='Profile') { var parent = sel_val(this.profile_sel); var parenttype = 'Profile'; }
|
if(sel_val(this.profile_or_role)=='Profile') { var parent = sel_val(this.profile_sel); var parenttype = 'Profile'; }
|
||||||
else { var parent = sel_val(this.role_sel); var parenttype = 'Role'; }
|
else { var parent = sel_val(this.role_sel); var parenttype = 'Role'; }
|
||||||
|
|
||||||
if(!sel_val(this.options_sel) || !parent) { msgprint("Please select all values"); return; }
|
if(!sel_val(this.options_sel) || !parent) { msgprint("Please select all values"); return; }
|
||||||
|
|
||||||
$c_obj('Permission Control','add_default'
|
$c_obj('Permission Control','add_default'
|
||||||
,[parent, parenttype, this.fieldname, sel_val(this.options_sel)].join('~~~')
|
,[parent, parenttype, this.fieldname, sel_val(this.options_sel)].join('~~~')
|
||||||
,callback);
|
,callback);
|
||||||
|
|
||||||
this.wrapper.innerHTML = '<div style="color: #888; padding: 3px;">Adding...</div>';
|
this.wrapper.innerHTML = '<div style="color: #888; padding: 3px;">Adding...</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -399,36 +423,36 @@ MatchDefaultValue.prototype.save = function() {
|
|||||||
// =======================================================
|
// =======================================================
|
||||||
|
|
||||||
pscript.PermEngine.prototype.make_fields_dialog=function(){
|
pscript.PermEngine.prototype.make_fields_dialog=function(){
|
||||||
if(!pscript.get_field_dialog) {
|
if(!pscript.get_field_dialog) {
|
||||||
pscript.get_field_dialog = new Dialog(750,500,'Fields');
|
pscript.get_field_dialog = new Dialog(750,500,'Fields');
|
||||||
pscript.get_field_dialog.make_body([['HTML','Fields','<div id="perm_engine_get_fields"></div>'],['Button','OK']]);
|
pscript.get_field_dialog.make_body([['HTML','Fields','<div id="perm_engine_get_fields"></div>'],['Button','OK']]);
|
||||||
}
|
}
|
||||||
else $i('perm_engine_get_fields').innerHTML = '';
|
else $i('perm_engine_get_fields').innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Fields
|
// Get Fields
|
||||||
// --------------------
|
// --------------------
|
||||||
pscript.PermEngine.prototype.get_fields = function(dt, permlevel) {
|
pscript.PermEngine.prototype.get_fields = function(dt, permlevel) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var callback = function(r,rt){
|
var callback = function(r,rt){
|
||||||
// Get Parent DocType Fields
|
// Get Parent DocType Fields
|
||||||
var parent_fields_dict = r.message.parent_fields_dict;
|
var parent_fields_dict = r.message.parent_fields_dict;
|
||||||
|
|
||||||
// Get Child Table Fields if any
|
// Get Child Table Fields if any
|
||||||
var table_fields_dict = r.message.table_fields_dict;
|
var table_fields_dict = r.message.table_fields_dict;
|
||||||
|
|
||||||
// Make Fields Dialog Box
|
// Make Fields Dialog Box
|
||||||
me.make_fields_dialog();
|
me.make_fields_dialog();
|
||||||
|
|
||||||
me.make_fields_table(dt, parent_fields_dict, table_fields_dict, permlevel);
|
me.make_fields_table(dt, parent_fields_dict, table_fields_dict, permlevel);
|
||||||
|
|
||||||
pscript.get_field_dialog.show();
|
pscript.get_field_dialog.show();
|
||||||
pscript.get_field_dialog.widgets['OK'].onclick=function(){
|
pscript.get_field_dialog.widgets['OK'].onclick=function(){
|
||||||
pscript.get_field_dialog.hide();
|
pscript.get_field_dialog.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var args = "{'dt':'"+dt+"','permlevel':"+permlevel+"}"
|
var args = "{'dt':'"+dt+"','permlevel':"+permlevel+"}"
|
||||||
$c_obj('Permission Control','get_fields', args, callback);
|
$c_obj('Permission Control','get_fields', args, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -437,89 +461,89 @@ pscript.PermEngine.prototype.get_fields = function(dt, permlevel) {
|
|||||||
// --------------------------------------
|
// --------------------------------------
|
||||||
pscript.PermEngine.prototype.make_fields_table = function(dt, parent_fields_dict, table_fields_dict, permlevel) {
|
pscript.PermEngine.prototype.make_fields_table = function(dt, parent_fields_dict, table_fields_dict, permlevel) {
|
||||||
|
|
||||||
var make_grid = function(table, fields_dict) {
|
var make_grid = function(table, fields_dict) {
|
||||||
var col_labels = ['Label','Fieldtype','Fieldname','Options'];
|
var col_labels = ['Label','Fieldtype','Fieldname','Options'];
|
||||||
for(var n = 0; n < col_labels.length; n++){
|
for(var n = 0; n < col_labels.length; n++){
|
||||||
$a_input(($td(table,0,n)), 'data');
|
$a_input(($td(table,0,n)), 'data');
|
||||||
$td(table,0,n).innerHTML = '<b>'+col_labels[n]+'</b>';
|
$td(table,0,n).innerHTML = '<b>'+col_labels[n]+'</b>';
|
||||||
$td(table,0,n).fieldname = col_labels[n].toLowerCase();
|
$td(table,0,n).fieldname = col_labels[n].toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add values
|
// Add values
|
||||||
for(var i = 0; i < keys(fields_dict).length; i++){
|
for(var i = 0; i < keys(fields_dict).length; i++){
|
||||||
for(var j = 0; j < 4; j++){
|
for(var j = 0; j < 4; j++){
|
||||||
$a_input(($td(table,i+1,j)), 'data');
|
$a_input(($td(table,i+1,j)), 'data');
|
||||||
$td(table,i+1,j).innerHTML = cstr(fields_dict[i][$td(table,0,j).fieldname])
|
$td(table,i+1,j).innerHTML = cstr(fields_dict[i][$td(table,0,j).fieldname])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$i('perm_engine_get_fields').innerHTML = '<b>'+ dt + ' Fields at Level '+ permlevel +':</b><br><br>';
|
$i('perm_engine_get_fields').innerHTML = '<b>'+ dt + ' Fields at Level '+ permlevel +':</b><br><br>';
|
||||||
var parent_field_table = make_table('perm_engine_get_fields',keys(parent_fields_dict).length+1, 4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});
|
var parent_field_table = make_table('perm_engine_get_fields',keys(parent_fields_dict).length+1, 4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});
|
||||||
make_grid(parent_field_table, parent_fields_dict);
|
make_grid(parent_field_table, parent_fields_dict);
|
||||||
|
|
||||||
child_tables = keys(table_fields_dict)
|
child_tables = keys(table_fields_dict)
|
||||||
if(child_tables.length > 0){
|
if(child_tables.length > 0){
|
||||||
for(var k = 0; k < child_tables.length; k++){
|
for(var k = 0; k < child_tables.length; k++){
|
||||||
var tab_fields_det = table_fields_dict[child_tables[k]];
|
var tab_fields_det = table_fields_dict[child_tables[k]];
|
||||||
if(keys(tab_fields_det).length > 0){
|
if(keys(tab_fields_det).length > 0){
|
||||||
$i('perm_engine_get_fields').innerHTML += '<br><b>'+ child_tables[k] + ' Fields at Level '+ permlevel +':</b><br><br>'
|
$i('perm_engine_get_fields').innerHTML += '<br><b>'+ child_tables[k] + ' Fields at Level '+ permlevel +':</b><br><br>'
|
||||||
var child_field_table = make_table('perm_engine_get_fields',keys(tab_fields_det).length+1, 4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});
|
var child_field_table = make_table('perm_engine_get_fields',keys(tab_fields_det).length+1, 4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});
|
||||||
make_grid(child_field_table, tab_fields_det);
|
make_grid(child_field_table, tab_fields_det);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update Permissions
|
// Update Permissions
|
||||||
// -----------------------
|
// -----------------------
|
||||||
pscript.PermEngine.prototype.update_permissions = function() {
|
pscript.PermEngine.prototype.update_permissions = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var out = {};
|
var out = {};
|
||||||
|
|
||||||
var add_to_out = function(doctype, permlevel, role, key, value) {
|
var add_to_out = function(doctype, permlevel, role, key, value) {
|
||||||
if(!out[doctype]) out[doctype] = {};
|
if(!out[doctype]) out[doctype] = {};
|
||||||
if(!out[doctype][permlevel]) out[doctype][permlevel] = {};
|
if(!out[doctype][permlevel]) out[doctype][permlevel] = {};
|
||||||
if(!out[doctype][permlevel][role]) out[doctype][permlevel][role] = {};
|
if(!out[doctype][permlevel][role]) out[doctype][permlevel][role] = {};
|
||||||
out[doctype][permlevel][role][key] = value;
|
out[doctype][permlevel][role][key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check boxes
|
// check boxes
|
||||||
for(i in pscript.all_checkboxes) {
|
for(i in pscript.all_checkboxes) {
|
||||||
c = pscript.all_checkboxes[i];
|
c = pscript.all_checkboxes[i];
|
||||||
add_to_out(c.doctype, c.permlevel, c.role, c.perm_type, c.checked ? 1 : 0);
|
add_to_out(c.doctype, c.permlevel, c.role, c.perm_type, c.checked ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// matches
|
// matches
|
||||||
for(var i=0; i<pscript.all_matches.length; i++) {
|
for(var i=0; i<pscript.all_matches.length; i++) {
|
||||||
var s = pscript.all_matches[i];
|
var s = pscript.all_matches[i];
|
||||||
if(sel_val(s))
|
if(sel_val(s))
|
||||||
add_to_out(s.details.parent, s.details.permlevel, s.details.role, 'match', sel_val(s));
|
add_to_out(s.details.parent, s.details.permlevel, s.details.role, 'match', sel_val(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = "{'perm_dict': "+JSON.stringify(out)+"}"
|
var args = "{'perm_dict': "+JSON.stringify(out)+"}"
|
||||||
$c_obj('Permission Control','update_permissions', args, function(r,rt) {});
|
$c_obj('Permission Control','update_permissions', args, function(r,rt) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update Page Roles
|
// Update Page Roles
|
||||||
// ----------------------
|
// ----------------------
|
||||||
pscript.PermEngine.prototype.update_page_roles = function() {
|
pscript.PermEngine.prototype.update_page_roles = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var out = {};
|
var out = {};
|
||||||
for(i in pscript.all_pg_checkboxes) {
|
for(i in pscript.all_pg_checkboxes) {
|
||||||
c = pscript.all_pg_checkboxes[i];
|
c = pscript.all_pg_checkboxes[i];
|
||||||
out[c.page_name] = c.checked ? 1 : 0
|
out[c.page_name] = c.checked ? 1 : 0
|
||||||
}
|
}
|
||||||
var args = "{'page_role_dict': "+JSON.stringify(out)+", 'role': '"+sel_val(me.role_select)+"'}"
|
var args = "{'page_role_dict': "+JSON.stringify(out)+", 'role': '"+sel_val(me.role_select)+"'}"
|
||||||
$c_obj('Permission Control','update_page_role', args, function(r,rt) {});
|
$c_obj('Permission Control','update_page_role', args, function(r,rt) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset Permission Engine
|
// Reset Permission Engine
|
||||||
// -------------------------
|
// -------------------------
|
||||||
pscript.PermEngine.prototype.reset_perm_engine = function(){
|
pscript.PermEngine.prototype.reset_perm_engine = function(){
|
||||||
this.type_select.selectedIndex = 0;
|
this.type_select.selectedIndex = 0;
|
||||||
this.load_options();
|
this.load_options();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ def on_login(login_manager):
|
|||||||
"""
|
"""
|
||||||
called from login manager, before login
|
called from login manager, before login
|
||||||
"""
|
"""
|
||||||
if login_manager.user not in ('Guest', None, ''):
|
if login_manager.user not in ('Guest', None, '') and webnotes.conn.cur_db_name!='accounts' and webnotes.conn.get_value('Control Panel', 'Control Panel', 'account_id')!='s5u011':
|
||||||
try:
|
try:
|
||||||
login_manager = login_as(login_manager)
|
login_manager = login_as(login_manager)
|
||||||
update_account_details()
|
update_account_details()
|
||||||
@@ -32,7 +32,7 @@ def on_login_post_session(login_manager):
|
|||||||
sid!=%s""", \
|
sid!=%s""", \
|
||||||
(webnotes.session['user'], webnotes.session['sid']), as_list=1)
|
(webnotes.session['user'], webnotes.session['sid']), as_list=1)
|
||||||
|
|
||||||
if webnotes.session['user'] not in ('Guest'):
|
if webnotes.session['user'] not in ('Guest') and webnotes.conn.cur_db_name!='accounts':
|
||||||
# create feed
|
# create feed
|
||||||
from webnotes.utils import nowtime
|
from webnotes.utils import nowtime
|
||||||
home.make_feed('Login', 'Profile', login_manager.user, login_manager.user,
|
home.make_feed('Login', 'Profile', login_manager.user, login_manager.user,
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-02-13 11:28:48',
|
'creation': '2012-02-02 11:50:33',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-02-13 11:28:48',
|
'modified': '2012-02-21 16:11:29',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
'from_doctype': u'Delivery Note',
|
'from_doctype': u'Delivery Note',
|
||||||
'module': u'Stock',
|
'module': u'Stock',
|
||||||
'name': '__common__',
|
'name': '__common__',
|
||||||
'ref_doc_submitted': 1,
|
'ref_doc_submitted': 0,
|
||||||
'to_doctype': u'Packing Slip'
|
'to_doctype': u'Packing Slip'
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
'from_table': u'Delivery Note',
|
'from_table': u'Delivery Note',
|
||||||
'match_id': 0,
|
'match_id': 0,
|
||||||
'to_table': u'Packing Slip',
|
'to_table': u'Packing Slip',
|
||||||
'validation_logic': u'docstatus=1'
|
'validation_logic': u'docstatus=0'
|
||||||
},
|
},
|
||||||
|
|
||||||
# Table Mapper Detail
|
# Table Mapper Detail
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
unhide_field(['SMS','Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
|
unhide_field(['SMS','Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus==1) {
|
if(doc.docstatus==0 && !doc.__islocal) {
|
||||||
cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
|
cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -318,6 +318,7 @@ class DocType(TransactionBase):
|
|||||||
# ON SUBMIT
|
# ON SUBMIT
|
||||||
# =================================================================================================
|
# =================================================================================================
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
self.validate_packed_qty()
|
||||||
set(self.doc, 'message', 'Items against your Order #%s have been delivered. Delivery #%s: ' % (self.doc.po_no, self.doc.name))
|
set(self.doc, 'message', 'Items against your Order #%s have been delivered. Delivery #%s: ' % (self.doc.po_no, self.doc.name))
|
||||||
self.check_qty_in_stock()
|
self.check_qty_in_stock()
|
||||||
# Check for Approving Authority
|
# Check for Approving Authority
|
||||||
@@ -335,6 +336,28 @@ class DocType(TransactionBase):
|
|||||||
set(self.doc, 'status', 'Submitted')
|
set(self.doc, 'status', 'Submitted')
|
||||||
|
|
||||||
|
|
||||||
|
def validate_packed_qty(self):
|
||||||
|
"""
|
||||||
|
Validate that if packed qty exists, it should be equal to qty
|
||||||
|
"""
|
||||||
|
if not any([d.fields.get('packed_qty') for d in self.doclist]):
|
||||||
|
return
|
||||||
|
packing_error_list = []
|
||||||
|
for d in self.doclist:
|
||||||
|
if d.doctype != 'Delivery Note Detail': continue
|
||||||
|
if d.fields.get('qty') != d.fields.get('packed_qty'):
|
||||||
|
packing_error_list.append([
|
||||||
|
d.fields.get('item_code', ''),
|
||||||
|
d.fields.get('qty', ''),
|
||||||
|
d.fields.get('packed_qty', '')
|
||||||
|
])
|
||||||
|
if packing_error_list:
|
||||||
|
from webnotes.utils import cstr
|
||||||
|
err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \
|
||||||
|
+ ", Packed: " + cstr(d[2])) for d in packing_error_list])
|
||||||
|
webnotes.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
# *********** Checks whether actual quantity is present in warehouse *************
|
# *********** Checks whether actual quantity is present in warehouse *************
|
||||||
def check_qty_in_stock(self):
|
def check_qty_in_stock(self):
|
||||||
for d in getlist(self.doclist, 'packing_details'):
|
for d in getlist(self.doclist, 'packing_details'):
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) {
|
||||||
return 'SELECT name FROM `tabDelivery Note` WHERE docstatus=1 AND %(key)s LIKE "%s"';
|
return 'SELECT name FROM `tabDelivery Note` WHERE docstatus=0 AND %(key)s LIKE "%s"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
||||||
return 'SELECT name, description FROM `tabItem` WHERE name IN ( \
|
return 'SELECT name, description FROM `tabItem` WHERE name IN ( \
|
||||||
SELECT item_code FROM `tabDelivery Note Detail` \
|
SELECT item_code FROM `tabDelivery Note Detail` dnd \
|
||||||
WHERE parent="' + doc.delivery_note + '") AND %(key)s LIKE "%s" LIMIT 50';
|
WHERE parent="' + doc.delivery_note + '" AND qty > packed_qty) AND %(key)s LIKE "%s" LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -39,8 +39,7 @@ cur_frm.cscript.update_item_details = function(doc) {
|
|||||||
if(r.exc) {
|
if(r.exc) {
|
||||||
msgprint(r.exc);
|
msgprint(r.exc);
|
||||||
} else {
|
} else {
|
||||||
refresh_field('item_details');
|
refresh_many(['item_details', 'naming_series', 'from_case_no', 'to_case_no'])
|
||||||
refresh_field('naming_series');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ class DocType:
|
|||||||
WHERE name=%(delivery_note)s
|
WHERE name=%(delivery_note)s
|
||||||
""", self.doc.fields)
|
""", self.doc.fields)
|
||||||
|
|
||||||
if not(res and res[0][0]==1):
|
if not(res and res[0][0]==0):
|
||||||
webnotes.msgprint("""Invalid Delivery Note. Delivery Note should exist
|
webnotes.msgprint("""Invalid Delivery Note. Delivery Note should exist
|
||||||
and should be submitted. Please rectify and try again.""", raise_exception=1)
|
and should be in draft state. Please rectify and try again.""",
|
||||||
|
raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
def validate_case_nos(self):
|
def validate_case_nos(self):
|
||||||
@@ -46,12 +47,8 @@ class DocType:
|
|||||||
""", self.doc.fields)
|
""", self.doc.fields)
|
||||||
|
|
||||||
if res:
|
if res:
|
||||||
recommended_case_no = webnotes.conn.sql("""\
|
|
||||||
SELECT MAX(to_case_no) FROM `tabPacking Slip`
|
|
||||||
WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields)
|
|
||||||
|
|
||||||
webnotes.msgprint("""Case No(s). already in use. Please rectify and try again.
|
webnotes.msgprint("""Case No(s). already in use. Please rectify and try again.
|
||||||
Recommended <b>From Case No. = %s</b>""" % (cint(recommended_case_no[0][0]) + 1),
|
Recommended <b>From Case No. = %s</b>""" % self.get_recommended_case_no(),
|
||||||
raise_exception=1)
|
raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
@@ -75,13 +72,18 @@ class DocType:
|
|||||||
* Item Quantity dict of current packing slip doc
|
* Item Quantity dict of current packing slip doc
|
||||||
* No. of Cases of this packing slip
|
* No. of Cases of this packing slip
|
||||||
"""
|
"""
|
||||||
item_codes = ", ".join([('"' + d.item_code + '"') for d in self.doclist])
|
item_codes = ", ".join([('"' + d.item_code + '"') for d in
|
||||||
|
self.doclist])
|
||||||
|
|
||||||
|
if not item_codes: webnotes.msgprint("No Items to Pack",
|
||||||
|
raise_exception=1)
|
||||||
|
|
||||||
res = webnotes.conn.sql("""\
|
res = webnotes.conn.sql("""\
|
||||||
SELECT item_code, IFNULL(SUM(qty), 0) as qty, IFNULL(packed_qty, 0) as packed_qty, stock_uom
|
SELECT item_code, IFNULL(SUM(qty), 0) as qty, IFNULL(packed_qty, 0) as packed_qty, stock_uom
|
||||||
FROM `tabDelivery Note Detail`
|
FROM `tabDelivery Note Detail`
|
||||||
WHERE parent = "%s" AND item_code IN (%s)
|
WHERE parent = "%s" AND item_code IN (%s)
|
||||||
GROUP BY item_code""" % (self.doc.delivery_note, item_codes), as_dict=1)
|
GROUP BY item_code""" % (self.doc.delivery_note, item_codes),
|
||||||
|
as_dict=1)
|
||||||
|
|
||||||
ps_item_qty = dict([[d.item_code, d.qty] for d in self.doclist])
|
ps_item_qty = dict([[d.item_code, d.qty] for d in self.doclist])
|
||||||
|
|
||||||
@@ -150,7 +152,23 @@ class DocType:
|
|||||||
"""
|
"""
|
||||||
Fill empty columns in Packing Slip Detail
|
Fill empty columns in Packing Slip Detail
|
||||||
"""
|
"""
|
||||||
|
self.doc.from_case_no = self.get_recommended_case_no()
|
||||||
|
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
for d in self.doclist:
|
for d in self.doclist:
|
||||||
psd_obj = get_obj(doc=d)
|
psd_obj = get_obj(doc=d)
|
||||||
psd_obj.get_item_details(self.doc.delivery_note)
|
psd_obj.get_item_details(self.doc.delivery_note)
|
||||||
|
|
||||||
|
|
||||||
|
def get_recommended_case_no(self):
|
||||||
|
"""
|
||||||
|
Returns the next case no. for a new packing slip for a delivery
|
||||||
|
note
|
||||||
|
"""
|
||||||
|
recommended_case_no = webnotes.conn.sql("""\
|
||||||
|
SELECT MAX(to_case_no) FROM `tabPacking Slip`
|
||||||
|
WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields)
|
||||||
|
|
||||||
|
return cint(recommended_case_no[0][0]) + 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-02-14 11:53:45',
|
'creation': '2012-02-17 15:53:22',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-02-22 18:28:20',
|
'modified': '2012-02-22 18:32:46',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user