diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js
index d35d6ceb85..14e35d3094 100644
--- a/accounts/doctype/account/account.js
+++ b/accounts/doctype/account/account.js
@@ -39,8 +39,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
'is_pl_account', 'company'], false);
// read-only for root accounts
- root_acc = doc.parent ? false : true;
- if(in_list(root_acc, doc.account_name)) {
+ if(!doc.parent_account) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root account and cannot be edited.");
} else {
diff --git a/accounts/doctype/budget_distribution/budget_distribution.js b/accounts/doctype/budget_distribution/budget_distribution.js
index c8bfe11525..5abd525999 100644
--- a/accounts/doctype/budget_distribution/budget_distribution.js
+++ b/accounts/doctype/budget_distribution/budget_distribution.js
@@ -21,7 +21,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
}
$c('runserverobj',args={'method' : 'get_months', 'docs' :
- compress_doclist(make_doclist(doc.doctype, doc.name))},callback1);
+ wn.model.compress(make_doclist(doc.doctype, doc.name))},callback1);
}
}
diff --git a/accounts/doctype/cost_center/cost_center.js b/accounts/doctype/cost_center/cost_center.js
index 08253837e7..3dde661b92 100644
--- a/accounts/doctype/cost_center/cost_center.js
+++ b/accounts/doctype/cost_center/cost_center.js
@@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_enable(['group_or_ledger', 'company_name'], doc.__islocal);
if(!doc.__islocal && doc.group_or_ledger=='Group') {
- intro_txt += '
Note: This is Cost Center is a Group, \
+ intro_txt += '
Note: This Cost Center is a Group, \
Accounting Entries are not allowed against groups.
';
}
diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js
index 784a134e5b..8c60838376 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/accounts/doctype/journal_voucher/journal_voucher.js
@@ -33,14 +33,14 @@ cur_frm.cscript.load_defaults = function(doc, cdt, cdn) {
if(!cur_frm.doc.__islocal || !cur_frm.doc.company) { return; }
doc = locals[doc.doctype][doc.name];
- var fields_to_refresh = LocalDB.set_default_values(doc);
+ var fields_to_refresh = wn.model.set_default_values(doc);
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
fields_to_refresh = null;
var children = getchildren('Journal Voucher Detail', doc.name, 'entries');
if(!children) { return; }
for(var i=0; i\
Create a new Task').click(function() {
wn.model.with_doctype('Task', function() {
- var new_name = LocalDB.create('Task');
+ var new_name = wn.model.make_new_doc_and_get_name('Task');
if(project)
locals.Task[new_name].project = project;
wn.set_route('Form', 'Task', new_name);
diff --git a/public/js/modules.js b/public/js/modules.js
index bb7488482d..b1a86ba9c1 100644
--- a/public/js/modules.js
+++ b/public/js/modules.js
@@ -111,7 +111,7 @@ erpnext.module_page.hide_links = function(wrapper) {
$(wrapper).find('[href*="List/"]').each(function() {
var href = $(this).attr('href');
var dt = href.split('/')[1];
- if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
+ if(wn.boot.profile.all_read.indexOf(dt)==-1) {
replace_link(this);
}
});
@@ -128,7 +128,7 @@ erpnext.module_page.hide_links = function(wrapper) {
$(wrapper).find('[href*="Form/"]').each(function() {
var href = $(this).attr('href');
var dt = href.split('/')[1];
- if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
+ if(wn.boot.profile.all_read.indexOf(dt)==-1) {
replace_link(this);
}
});
diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js
index d20b0c927d..845f543467 100644
--- a/selling/doctype/customer/customer.js
+++ b/selling/doctype/customer/customer.js
@@ -35,7 +35,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
doc = locals[doc.doctype][doc.name];
if(!(doc.__islocal && doc.lead_name)) { return; }
- var fields_to_refresh = LocalDB.set_default_values(doc);
+ var fields_to_refresh = wn.model.set_default_values(doc);
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
}
@@ -89,7 +89,7 @@ cur_frm.cscript.make_contact = function() {
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
custom_new_doc: function(doctype) {
- var contact = LocalDB.create('Contact');
+ var contact = wn.model.make_new_doc_and_get_name('Contact');
contact = locals['Contact'][contact];
contact.customer = cur_frm.doc.name;
contact.customer_name = cur_frm.doc.customer_name;
diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js
index 0c5bf87cdb..9dd64de25d 100644
--- a/selling/doctype/lead/lead.js
+++ b/selling/doctype/lead/lead.js
@@ -71,7 +71,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
list: wn.model.get("Communication", {"lead": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
- email: doc.email_id
+ recipients: doc.email_id
})
}
@@ -83,15 +83,15 @@ cur_frm.cscript.status = function(doc, cdt, cdn){
cur_frm.cscript['Create Customer'] = function(){
var doc = cur_frm.doc;
- $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
+ $c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is already converted to customer");
}
else{
- n = createLocal("Customer");
+ n = wn.model.make_new_doc_and_get_name("Customer");
$c('dt_map', args={
- 'docs':compress_doclist([locals["Customer"][n]]),
+ 'docs':wn.model.compress([locals["Customer"][n]]),
'from_doctype':'Lead',
'to_doctype':'Customer',
'from_docname':doc.name,
@@ -110,15 +110,15 @@ cur_frm.cscript['Create Customer'] = function(){
// ===============================================================
cur_frm.cscript['Create Opportunity'] = function(){
var doc = cur_frm.doc;
- $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
+ $c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
}
else{
- n = createLocal("Opportunity");
+ n = wn.model.make_new_doc_and_get_name("Opportunity");
$c('dt_map', args={
- 'docs':compress_doclist([locals["Opportunity"][n]]),
+ 'docs':wn.model.compress([locals["Opportunity"][n]]),
'from_doctype':'Lead',
'to_doctype':'Opportunity',
'from_docname':doc.name,
diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js
index 2bb41b21b5..cfc546c956 100644
--- a/selling/doctype/opportunity/opportunity.js
+++ b/selling/doctype/opportunity/opportunity.js
@@ -51,7 +51,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
list: wn.model.get("Communication", {"opportunity": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
- email: doc.contact_email
+ recipients: doc.contact_email
});
}
@@ -156,9 +156,9 @@ cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = f
// Create New Quotation
cur_frm.cscript['Create Quotation'] = function(){
- n = createLocal("Quotation");
+ n = wn.model.make_new_doc_and_get_name("Quotation");
$c('dt_map', args={
- 'docs':compress_doclist([locals["Quotation"][n]]),
+ 'docs':wn.model.compress([locals["Quotation"][n]]),
'from_doctype':'Opportunity',
'to_doctype':'Quotation',
'from_docname':cur_frm.docname,
@@ -207,6 +207,7 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){
if(r.message == 'true'){
$i('update_enquiry_dialog_response').innerHTML = 'Done';
e_lost_dialog.hide();
+ cur_frm.refresh();
}
}
if(arg) {
diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index 1b03781b5b..1b0a7748a9 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -107,7 +107,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
list: wn.model.get("Communication", {"quotation": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
- email: doc.contact_email
+ recipients: doc.contact_email
});
}
}
@@ -180,9 +180,9 @@ cur_frm.cscript['Make Sales Order'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
- var n = createLocal("Sales Order");
+ var n = wn.model.make_new_doc_and_get_name("Sales Order");
$c('dt_map', args={
- 'docs':compress_doclist([locals["Sales Order"][n]]),
+ 'docs':wn.model.compress([locals["Sales Order"][n]]),
'from_doctype':'Quotation',
'to_doctype':'Sales Order',
'from_docname':doc.name,
@@ -250,6 +250,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){
if(r.message == 'true'){
$i('update_quotation_dialog_response').innerHTML = 'Done';
qtn_lost_dialog.hide();
+ cur_frm.refresh();
}
}
if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back);
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index c5eed98f71..de56a6c113 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -46,14 +46,14 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
if(!cur_frm.doc.__islocal) { return; }
doc = locals[doc.doctype][doc.name];
- var fields_to_refresh = LocalDB.set_default_values(doc);
+ var fields_to_refresh = wn.model.set_default_values(doc);
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
fields_to_refresh = null;
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(!children) { return; }
for(var i=0; i getdate(self.doc.transaction_date):
@@ -229,14 +229,13 @@ class DocType(TransactionBase):
# used for production plan
d.transaction_date = self.doc.transaction_date
-
- # gets total projected qty of item in warehouse selected (this case arises when warehouse is selected b4 item)
- tot_avail_qty = sql("select projected_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse))
+
+ tot_avail_qty = sql("select projected_qty from `tabBin` \
+ where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse))
d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0
- if flag == 0:
- msgprint("There are no items of the quotation selected.")
- raise Exception
+ if getlist(self.doclist, 'sales_order_details') and self.doc.quotation_no and flag == 0:
+ msgprint("There are no items of the quotation selected", raise_exception=1)
# validate sales/ maintenance quotation against order type
#------------------------------------------------------------------
diff --git a/selling/page/sales_browser/sales_browser.js b/selling/page/sales_browser/sales_browser.js
index ce495dbebd..be43e67783 100644
--- a/selling/page/sales_browser/sales_browser.js
+++ b/selling/page/sales_browser/sales_browser.js
@@ -24,7 +24,14 @@ pscript['onload_Sales Browser'] = function(wrapper){
wrapper.make_tree = function() {
var ctype = wn.get_route()[1] || 'Territory';
- erpnext.sales_chart = new erpnext.SalesChart(ctype, wrapper);
+ wn.call({
+ method: 'selling.page.sales_browser.sales_browser.get_children',
+ args: {ctype: ctype},
+ callback: function(r) {
+ var root = r.message[0]["value"];
+ erpnext.sales_chart = new erpnext.SalesChart(ctype, root, wrapper);
+ }
+ });
}
wrapper.make_tree();
@@ -42,20 +49,13 @@ pscript['onshow_Sales Browser'] = function(wrapper){
};
erpnext.SalesChart = Class.extend({
- init: function(ctype, wrapper) {
- var root_nodes = {
- 'Territory': 'All Territories',
- 'Item Group': 'All Item Groups',
- 'Customer Group': 'All Customer Groups',
- 'Sales Person': 'All Sales Persons'
- }
-
+ init: function(ctype, root, wrapper) {
$(wrapper).find('.tree-area').empty();
var me = this;
me.ctype = ctype;
this.tree = new wn.ui.Tree({
parent: $(wrapper).find('.tree-area'),
- label: root_nodes[ctype],
+ label: root,
args: {ctype: ctype},
method: 'selling.page.sales_browser.sales_browser.get_children',
click: function(link) {
@@ -72,7 +72,7 @@ erpnext.SalesChart = Class.extend({
}
});
this.tree.rootnode.$a
- .data('node-data', {value: root_nodes[ctype], expandable:1})
+ .data('node-data', {value: root, expandable:1})
.click();
},
make_link_toolbar: function(link) {
diff --git a/selling/page/sales_browser/sales_browser.py b/selling/page/sales_browser/sales_browser.py
index 92c75e0fcd..49a05ff578 100644
--- a/selling/page/sales_browser/sales_browser.py
+++ b/selling/page/sales_browser/sales_browser.py
@@ -1,11 +1,14 @@
from __future__ import unicode_literals
import webnotes
+
@webnotes.whitelist()
def get_children():
ctype = webnotes.form_dict.get('ctype')
webnotes.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_')
-
+ if not webnotes.form_dict.get('parent'):
+ webnotes.form_dict['parent'] = ''
+
return webnotes.conn.sql("""select name as value,
if(is_group='Yes', 1, 0) as expandable
from `tab%(ctype)s`
diff --git a/setup/doctype/authorization_control/authorization_control.py b/setup/doctype/authorization_control/authorization_control.py
index 9e0d979f30..9455f8a874 100644
--- a/setup/doctype/authorization_control/authorization_control.py
+++ b/setup/doctype/authorization_control/authorization_control.py
@@ -60,7 +60,7 @@ class DocType(TransactionBase):
if appr_users: add_msg = "Users : "+cstr(appr_users)
if appr_roles: add_msg = "Roles : "+cstr(appr_roles)
if appr_users and appr_roles: add_msg = "Users : "+cstr(appr_users)+" or "+"Roles : "+cstr(appr_roles)
- msgprint("You do not have an authority to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg))
+ msgprint("You are not authorize to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg))
raise Exception
diff --git a/setup/doctype/authorization_rule/authorization_rule.js b/setup/doctype/authorization_rule/authorization_rule.js
index b29d88915e..184c761b9d 100644
--- a/setup/doctype/authorization_rule/authorization_rule.js
+++ b/setup/doctype/authorization_rule/authorization_rule.js
@@ -26,13 +26,13 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.refresh = function(doc,cdt,cdn){
- if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Total Claimed Amount' || doc.based_on == 'Not Applicable') hide_field('master_name');
+ if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Not Applicable') hide_field('master_name');
else unhide_field('master_name');
if(doc.based_on == 'Not Applicable') hide_field('value');
else unhide_field('value');
- if(doc.transaction == 'Expense Claim' || doc.transaction == 'Appraisal'){
+ if(doc.transaction == 'Appraisal'){
hide_field(['master_name','system_role', 'system_user']);
unhide_field(['to_emp','to_designation']);
if(doc.transaction == 'Appraisal') hide_field('value');
@@ -45,7 +45,7 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){
}
cur_frm.cscript.based_on = function(doc){
- if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Total Claimed Amount' || doc.based_on == 'Not Applicable'){
+ if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Not Applicable'){
doc.master_name = '';
refresh_field('master_name');
hide_field('master_name');
@@ -63,24 +63,20 @@ cur_frm.cscript.based_on = function(doc){
}
cur_frm.cscript.transaction = function(doc,cdt,cdn){
- if(doc.transaction == 'Expense Claim' || doc.transaction == 'Appraisal'){
+ if (doc.transaction == 'Appraisal'){
doc.master_name = doc.system_role = doc.system_user = '';
refresh_many(['master_name','system_role', 'system_user']);
hide_field(['master_name','system_role', 'system_user']);
unhide_field(['to_emp','to_designation']);
- if(doc.transaction == 'Appraisal') {
- doc.value =0;
- refresh_many('value');
- hide_field('value');
- }
- else unhide_field('value');
+ doc.value =0;
+ refresh_many('value');
+ hide_field('value');
}
else {
unhide_field(['master_name','system_role', 'system_user','value']);
hide_field(['to_emp','to_designation']);
}
- if(doc.transaction == 'Expense Claim') doc.based_on = 'Total Claimed Amount';
if(doc.transaction == 'Appraisal') doc.based_on == 'Not Applicable';
}
diff --git a/setup/doctype/authorization_rule/authorization_rule.py b/setup/doctype/authorization_rule/authorization_rule.py
index a3646c06ae..be6c0aee33 100644
--- a/setup/doctype/authorization_rule/authorization_rule.py
+++ b/setup/doctype/authorization_rule/authorization_rule.py
@@ -8,11 +8,11 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
+# along with this program. If not, see .
from __future__ import unicode_literals
import webnotes
@@ -27,74 +27,80 @@ sql = webnotes.conn.sql
class DocType:
- def __init__(self, d, dl):
- self.doc, self.doclist = d, dl
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
- # Duplicate Entry
- # ----------------
- def check_duplicate_entry(self):
- exists = sql("select name, docstatus from `tabAuthorization Rule` where transaction = %s and based_on = %s and system_user = %s and system_role = %s and approving_user = %s and approving_role = %s and to_emp =%s and to_designation=%s and name != %s", (self.doc.transaction, self.doc.based_on, cstr(self.doc.system_user), cstr(self.doc.system_role), cstr(self.doc.approving_user), cstr(self.doc.approving_role), cstr(self.doc.to_emp), cstr(self.doc.to_designation), self.doc.name))
- auth_exists = exists and exists[0][0] or ''
- if auth_exists:
- if cint(exists[0][1]) == 2:
- msgprint("Duplicate Entry. Please remove from trash Authorization Rule : %s." %(auth_exists))
- raise Exception
- else:
- msgprint("Duplicate Entry. Please check Authorization Rule : %s." % (auth_exists))
- raise Exception
+ def check_duplicate_entry(self):
+ exists = sql("""select name, docstatus from `tabAuthorization Rule`
+ where transaction = %s and based_on = %s and system_user = %s
+ and system_role = %s and approving_user = %s and approving_role = %s
+ and to_emp =%s and to_designation=%s and name != %s""",
+ (self.doc.transaction, self.doc.based_on, cstr(self.doc.system_user),
+ cstr(self.doc.system_role), cstr(self.doc.approving_user),
+ cstr(self.doc.approving_role), cstr(self.doc.to_emp),
+ cstr(self.doc.to_designation), self.doc.name))
+ auth_exists = exists and exists[0][0] or ''
+ if auth_exists:
+ if cint(exists[0][1]) == 2:
+ msgprint("""Duplicate Entry. Please untrash Authorization Rule : %s \
+ from Recycle Bin""" % (auth_exists), raise_exception=1)
+ else:
+ msgprint("Duplicate Entry. Please check Authorization Rule : %s" %
+ (auth_exists), raise_exception=1)
- # Validate Master Name
- # ---------------------
- def validate_master_name(self):
- if self.doc.based_on == 'Customerwise Discount' and not sql("select name from tabCustomer where name = '%s' and docstatus != 2" % (self.doc.master_name)):
- msgprint("Please select valid Customer Name for Customerwise Discount.")
- raise Exception
- elif self.doc.based_on == 'Itemwise Discount' and not sql("select name from tabItem where name = '%s' and docstatus != 2" % (self.doc.master_name)):
- msgprint("Please select valid Item Name for Itemwise Discount.")
- raise Exception
- elif (self.doc.based_on == 'Grand Total' or self.doc.based_on == 'Average Discount') and self.doc.master_name:
- msgprint("Please remove Customer / Item Name for %s." % (self.doc.based_on))
- raise Exception
+ def validate_master_name(self):
+ if self.doc.based_on == 'Customerwise Discount' and \
+ not sql("select name from tabCustomer where name = '%s' and docstatus != 2" % \
+ (self.doc.master_name)):
+ msgprint("Please select valid Customer Name for Customerwise Discount",
+ raise_exception=1)
+ elif self.doc.based_on == 'Itemwise Discount' and \
+ not sql("select name from tabItem where name = '%s' and docstatus != 2" % \
+ (self.doc.master_name)):
+ msgprint("Please select valid Item Name for Itemwise Discount", raise_exception=1)
+ elif (self.doc.based_on == 'Grand Total' or \
+ self.doc.based_on == 'Average Discount') and self.doc.master_name:
+ msgprint("Please remove Customer/Item Name for %s." %
+ self.doc.based_on, raise_exception=1)
- # Validate Rule
- # --------------
- def validate_rule(self):
- if not self.doc.transaction == 'Expense Claim' and not self.doc.transaction == 'Appraisal':
- if not self.doc.approving_role and not self.doc.approving_user:
- msgprint("Please enter Approving Role or Approving User")
- raise Exception
- elif self.doc.system_user and self.doc.system_user == self.doc.approving_user:
- msgprint("Approving User cannot be same as user the rule is Applicable To (User).")
- raise Exception
- elif self.doc.system_role and self.doc.system_role == self.doc.approving_role:
- msgprint("Approving Role cannot be same as user the rule is Applicable To (Role).")
- raise Exception
- elif self.doc.system_user and self.doc.approving_role and has_common([self.doc.approving_role],[x[0] for x in sql("select role from `tabUserRole` where parent = '%s'" % (self.doc.system_user))]):
- msgprint("System User : %s is assigned role : %s. So rule does not make sense." % (self.doc.system_user,self.doc.approving_role))
- raise Exception
- elif (self.doc.transaction == 'Purchase Order' or self.doc.transaction == 'Purchase Receipt' or self.doc.transaction == 'Purchase Invoice' or self.doc.transaction == 'Stock Entry') and (self.doc.based_on == 'Average Discount' or self.doc.based_on == 'Customerwise Discount' or self.doc.based_on == 'Itemwise Discount'):
- msgprint("You cannot set authorization on basis of Discount for %s." % (self.doc.transaction))
- raise Exception
- elif self.doc.based_on == 'Average Discount' and flt(self.doc.value) > 100.00:
- msgprint("Discount cannot given for more than 100 %s." % ('%'))
- raise Exception
- elif self.doc.based_on == 'Customerwise Discount' and not self.doc.master_name:
- msgprint("Please enter Customer Name for 'Customerwise Discount'")
- raise Exception
- else:
- if self.doc.transaction == 'Appraisal' and self.doc.based_on != 'Not Applicable':
- msgprint("Based on is 'Not Applicable' while setting authorization rule for 'Appraisal'")
- raise Exception
- if self.doc.transaction == 'Expense Claim' and self.doc.based_on != 'Total Claimed Amount':
- msgprint("Authorization rule should be based on 'Total Calimed Amount' while setting authorization rule for 'Expense Claim'")
- raise Exception
+ def validate_rule(self):
+ if self.doc.transaction != 'Appraisal':
+ if not self.doc.approving_role and not self.doc.approving_user:
+ msgprint("Please enter Approving Role or Approving User", raise_exception=1)
+ elif self.doc.system_user and self.doc.system_user == self.doc.approving_user:
+ msgprint("Approving User cannot be same as user the rule is Applicable To (User)",
+ raise_exception=1)
+ elif self.doc.system_role and self.doc.system_role == self.doc.approving_role:
+ msgprint("Approving Role cannot be same as user the rule is \
+ Applicable To (Role).", raise_exception=1)
+ elif self.doc.system_user and self.doc.approving_role and \
+ has_common([self.doc.approving_role], [x[0] for x in \
+ sql("select role from `tabUserRole` where parent = '%s'" % \
+ (self.doc.system_user))]):
+ msgprint("System User : %s is assigned role : %s. So rule does not make sense" %
+ (self.doc.system_user,self.doc.approving_role), raise_exception=1)
+ elif self.doc.transaction in ['Purchase Order', 'Purchase Receipt', \
+ 'Purchase Invoice', 'Stock Entry'] and self.doc.based_on \
+ in ['Average Discount', 'Customerwise Discount', 'Itemwise Discount']:
+ msgprint("You cannot set authorization on basis of Discount for %s" %
+ self.doc.transaction, raise_exception=1)
+ elif self.doc.based_on == 'Average Discount' and flt(self.doc.value) > 100.00:
+ msgprint("Discount cannot given for more than 100%", raise_exception=1)
+ elif self.doc.based_on == 'Customerwise Discount' and not self.doc.master_name:
+ msgprint("Please enter Customer Name for 'Customerwise Discount'",
+ raise_exception=1)
+ else:
+ if self.doc.transaction == 'Appraisal' and self.doc.based_on != 'Not Applicable':
+ msgprint("Based on should be 'Not Applicable' while setting authorization rule\
+ for 'Appraisal'", raise_exception=1)
- def validate(self):
- self.check_duplicate_entry()
- self.validate_rule()
- self.validate_master_name()
- if not self.doc.value: self.doc.value = flt(0)
\ No newline at end of file
+
+ def validate(self):
+ self.check_duplicate_entry()
+ self.validate_rule()
+ self.validate_master_name()
+ if not self.doc.value: self.doc.value = 0.0
\ No newline at end of file
diff --git a/setup/doctype/authorization_rule/authorization_rule.txt b/setup/doctype/authorization_rule/authorization_rule.txt
index d62155880f..7061da37b1 100644
--- a/setup/doctype/authorization_rule/authorization_rule.txt
+++ b/setup/doctype/authorization_rule/authorization_rule.txt
@@ -2,23 +2,17 @@
{
"owner": "Administrator",
"docstatus": 0,
- "creation": "2012-03-27 14:36:18",
+ "creation": "2012-07-03 13:30:00",
"modified_by": "Administrator",
- "modified": "2012-03-27 14:36:18"
+ "modified": "2012-12-12 10:42:42"
},
{
- "section_style": "Simple",
+ "autoname": "AR.####",
+ "name": "__common__",
"search_fields": "transaction,based_on,system_user,system_role,approving_user,approving_role",
"module": "Setup",
"doctype": "DocType",
- "allow_trash": 1,
- "document_type": "Master",
- "autoname": "AR.####",
- "name": "__common__",
- "colour": "White:FFF",
- "_last_update": "1308741898",
- "server_code_error": " ",
- "version": 58
+ "document_type": "Master"
},
{
"name": "__common__",
@@ -46,19 +40,13 @@
"doctype": "DocType"
},
{
- "doctype": "DocPerm"
- },
- {
- "doctype": "DocPerm"
- },
- {
- "search_index": 0,
+ "oldfieldtype": "Link",
"doctype": "DocField",
"label": "Company",
"oldfieldname": "company",
"fieldname": "company",
"fieldtype": "Link",
- "oldfieldtype": "Link",
+ "search_index": 0,
"reqd": 0,
"options": "Company"
},
@@ -70,27 +58,26 @@
"fieldname": "transaction",
"fieldtype": "Select",
"reqd": 1,
- "options": "\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nStock Entry\nExpense Claim\nAppraisal"
+ "options": "\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nStock Entry\nAppraisal"
},
{
"oldfieldtype": "Select",
"doctype": "DocField",
"label": "Based On",
"oldfieldname": "based_on",
- "trigger": "Client",
"fieldname": "based_on",
"fieldtype": "Select",
"reqd": 1,
- "options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nTotal Claimed Amount\nNot Applicable"
+ "options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable"
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Customer / Item Name",
"oldfieldname": "master_name",
- "trigger": "Client",
"fieldname": "master_name",
- "fieldtype": "Link"
+ "fieldtype": "Link",
+ "options": "[Select]"
},
{
"oldfieldtype": "Link",
@@ -103,7 +90,6 @@
},
{
"oldfieldtype": "Link",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Applicable To (User)",
"oldfieldname": "system_user",
@@ -113,26 +99,24 @@
},
{
"description": "This will be used for setting rule in HR module",
- "search_index": 0,
- "colour": "White:FFF",
+ "oldfieldtype": "Link",
"doctype": "DocField",
"label": "Applicable To (Employee)",
"oldfieldname": "to_emp",
"fieldname": "to_emp",
"fieldtype": "Link",
- "oldfieldtype": "Link",
+ "search_index": 0,
"options": "Employee"
},
{
"description": "This will be used for setting rule in HR module",
- "search_index": 0,
- "colour": "White:FFF",
+ "oldfieldtype": "Link",
"doctype": "DocField",
"label": "Applicable To (Designation)",
"oldfieldname": "to_designation",
"fieldname": "to_designation",
"fieldtype": "Link",
- "oldfieldtype": "Link",
+ "search_index": 0,
"options": "Designation"
},
{
@@ -169,5 +153,11 @@
"oldfieldname": "trash_reason",
"fieldname": "trash_reason",
"fieldtype": "Small Text"
+ },
+ {
+ "doctype": "DocPerm"
+ },
+ {
+ "doctype": "DocPerm"
}
]
\ No newline at end of file
diff --git a/setup/doctype/contact_control/contact_control.js b/setup/doctype/contact_control/contact_control.js
index faadc6ad3d..fd08062a0e 100755
--- a/setup/doctype/contact_control/contact_control.js
+++ b/setup/doctype/contact_control/contact_control.js
@@ -55,7 +55,7 @@ cur_frm.cscript.make_history_list = function(parent,doc){
// get sates on country trigger
// -----------------------------
cur_frm.cscript.get_states=function(doc,dt,dn){
- $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
+ $c('runserverobj', args={'method':'check_state', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
function(r,rt){
if(r.message) {
set_field_options('state', r.message);
@@ -156,7 +156,7 @@ cur_frm.cscript.render_row_in_wrapper = function(wrapper, data, doctype) {
$wrapper.append(repl("\
\
", data));
diff --git a/setup/doctype/customer_group/customer_group.js b/setup/doctype/customer_group/customer_group.js
index 2b24c11efe..af0c6f0b44 100644
--- a/setup/doctype/customer_group/customer_group.js
+++ b/setup/doctype/customer_group/customer_group.js
@@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root customer group
- if(doc.name==='All Customer Groups') {
+ if(!doc.parent_customer_group) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root customer group and cannot be edited.");
} else {
diff --git a/setup/doctype/customer_group/customer_group.py b/setup/doctype/customer_group/customer_group.py
index 0f68521198..cf126b8c07 100644
--- a/setup/doctype/customer_group/customer_group.py
+++ b/setup/doctype/customer_group/customer_group.py
@@ -31,20 +31,29 @@ class DocType(DocTypeNestedSet):
self.nsm_parent_field = 'parent_customer_group';
def validate(self):
- if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)):
+ if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2",
+ (self.doc.customer_group_name)):
msgprint("""Another %s record is trashed.
- To untrash please go to Setup & click on Trash."""%(self.doc.customer_group_name), raise_exception = 1)
- self.validate_root_details("All Customer Groups", "parent_customer_group")
+ To untrash please go to Setup -> Recycle Bin.""" %
+ (self.doc.customer_group_name), raise_exception = 1)
+
+ super(DocType, self).validate()
+
def on_trash(self):
- cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", self.doc.name)
+ cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s",
+ self.doc.name)
cust = [d[0] for d in cust]
if cust:
- msgprint("""Customer Group: %s can not be trashed/deleted because it is used in customer: %s.
- To trash/delete this, remove/change customer group in customer master""" % (self.doc.name, cust or ''), raise_exception=1)
+ msgprint("""Customer Group: %s can not be trashed/deleted \
+ because it is used in customer: %s.
+ To trash/delete this, remove/change customer group in customer master""" %
+ (self.doc.name, cust or ''), raise_exception=1)
- if sql("select name from `tabCustomer Group` where parent_customer_group = %s and docstatus != 2", self.doc.name):
- msgprint("Child customer group exists for this customer group. You can not trash/cancel/delete this customer group.", raise_exception=1)
+ if sql("select name from `tabCustomer Group` where parent_customer_group = %s \
+ and docstatus != 2", self.doc.name):
+ msgprint("Child customer group exists for this customer group. \
+ You can not trash/cancel/delete this customer group.", raise_exception=1)
# rebuild tree
- super(DocType, self).on_trash()
+ super(DocType, self).on_trash()
\ No newline at end of file
diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py
index 13a42ed766..5aa2c9acfc 100644
--- a/setup/doctype/global_defaults/global_defaults.py
+++ b/setup/doctype/global_defaults/global_defaults.py
@@ -37,7 +37,8 @@ keydict = {
'currency_format':'default_currency_format',
'account_url':'account_url',
'allow_negative_stock' : 'allow_negative_stock',
- 'maintain_same_rate' : 'maintain_same_rate'
+ 'maintain_same_rate' : 'maintain_same_rate',
+ 'session_expiry': 'session_expiry'
}
class DocType:
@@ -47,6 +48,8 @@ class DocType:
def on_update(self):
"""update defaults"""
+ self.validate_session_expiry()
+
for key in keydict:
webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
@@ -60,6 +63,15 @@ class DocType:
webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
webnotes.conn.set_default('year_end_date', \
get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
-
+
+ def validate_session_expiry(self):
+ if self.doc.session_expiry:
+ from datetime import datetime
+ try:
+ datetime.strptime(self.doc.session_expiry, "%H:%M")
+ except ValueError:
+ webnotes.msgprint("""Session Expiry must be in format hh:mm""",
+ raise_exception=1)
+
def get_defaults(self):
return webnotes.conn.get_defaults()
diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt
index ece7fac68a..e4b36a9abc 100644
--- a/setup/doctype/global_defaults/global_defaults.txt
+++ b/setup/doctype/global_defaults/global_defaults.txt
@@ -2,25 +2,19 @@
{
"owner": "Administrator",
"docstatus": 0,
- "creation": "2012-07-03 13:30:02",
+ "creation": "2012-10-26 16:49:40",
"modified_by": "Administrator",
- "modified": "2012-10-26 16:42:29"
+ "modified": "2012-12-12 14:13:31"
},
{
- "section_style": "Tabbed",
"in_create": 1,
"allow_print": 1,
"module": "Setup",
- "doctype": "DocType",
- "server_code_error": " ",
"read_only": 1,
"allow_email": 1,
"issingle": 1,
"name": "__common__",
- "colour": "White:FFF",
- "_last_update": "1323855502",
- "show_in_menu": 1,
- "version": 1,
+ "doctype": "DocType",
"hide_toolbar": 0,
"allow_copy": 1
},
@@ -46,9 +40,22 @@
},
{
"doctype": "DocField",
+ "label": "General",
+ "fieldname": "general",
+ "fieldtype": "Section Break"
+ },
+ {
+ "description": "Session Expiry in Hours e.g. 06:00",
+ "doctype": "DocField",
+ "label": "Session Expiry",
+ "fieldname": "session_expiry",
+ "fieldtype": "Data"
+ },
+ {
+ "doctype": "DocField",
+ "label": "Company",
"fieldname": "company",
- "fieldtype": "Section Break",
- "label": "Company"
+ "fieldtype": "Section Break"
},
{
"doctype": "DocField",
@@ -74,10 +81,10 @@
"options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy"
},
{
+ "doctype": "DocField",
"width": "50%",
"fieldname": "column_break1",
- "fieldtype": "Column Break",
- "doctype": "DocField"
+ "fieldtype": "Column Break"
},
{
"default": "INR",
@@ -97,21 +104,21 @@
},
{
"doctype": "DocField",
+ "label": "Default Currency Fraction",
"fieldname": "default_currency_fraction",
- "fieldtype": "Data",
- "label": "Default Currency Fraction"
+ "fieldtype": "Data"
},
{
"doctype": "DocField",
+ "label": "Stock",
"fieldname": "stock",
- "fieldtype": "Section Break",
- "label": "Stock"
+ "fieldtype": "Section Break"
},
{
+ "doctype": "DocField",
"width": "50%",
"fieldname": "column_break2",
- "fieldtype": "Column Break",
- "doctype": "DocField"
+ "fieldtype": "Column Break"
},
{
"doctype": "DocField",
@@ -143,7 +150,6 @@
},
{
"description": "Applicable only if valuation method is moving average",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Allow Negative Stock",
"fieldname": "allow_negative_stock",
@@ -158,9 +164,9 @@
},
{
"doctype": "DocField",
+ "label": "Raise Purchase Request when stock reaches re-order level",
"fieldname": "auto_indent",
- "fieldtype": "Check",
- "label": "Raise Purchase Request when stock reaches re-order level"
+ "fieldtype": "Check"
},
{
"default": "1",
@@ -171,7 +177,6 @@
},
{
"description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units
",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Allowance Percent",
"fieldname": "tolerance",
@@ -179,7 +184,6 @@
},
{
"description": "Stock level frozen up to this date, nobody can do / modify entry except authorized person",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Stock Frozen Upto",
"fieldname": "stock_frozen_upto",
@@ -187,7 +191,6 @@
},
{
"description": "Users with this role are allowed to do / modify stock entry before frozen date",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Authorized Role (Frozen Entry)",
"fieldname": "stock_auth_role",
@@ -196,13 +199,12 @@
},
{
"doctype": "DocField",
+ "label": "Accounts",
"fieldname": "accounts",
- "fieldtype": "Section Break",
- "label": "Accounts"
+ "fieldtype": "Section Break"
},
{
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except authorized person",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Accounts Frozen Upto",
"fieldname": "acc_frozen_upto",
@@ -210,7 +212,6 @@
},
{
"description": "Users with this role are allowed to do / modify accounting entry before frozen date",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Authourized Role (Frozen Entry)",
"fieldname": "bde_auth_role",
@@ -225,9 +226,9 @@
"options": "Role"
},
{
+ "doctype": "DocField",
"fieldname": "column_break4",
- "fieldtype": "Column Break",
- "doctype": "DocField"
+ "fieldtype": "Column Break"
},
{
"doctype": "DocField",
@@ -238,13 +239,12 @@
},
{
"doctype": "DocField",
+ "label": "Selling",
"fieldname": "selling",
- "fieldtype": "Section Break",
- "label": "Selling"
+ "fieldtype": "Section Break"
},
{
"default": "Customer Name",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Customer Master created by ",
"fieldname": "cust_master_name",
@@ -280,10 +280,10 @@
"options": "To manage Territory, click here"
},
{
+ "doctype": "DocField",
"width": "50%",
"fieldname": "column_break5",
- "fieldtype": "Column Break",
- "doctype": "DocField"
+ "fieldtype": "Column Break"
},
{
"doctype": "DocField",
@@ -301,7 +301,6 @@
},
{
"default": "No",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Sales Order Required",
"fieldname": "so_required",
@@ -310,7 +309,6 @@
},
{
"default": "No",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Delivery Note Required",
"fieldname": "dn_required",
@@ -319,9 +317,9 @@
},
{
"doctype": "DocField",
+ "label": "Buying",
"fieldname": "buying",
- "fieldtype": "Section Break",
- "label": "Buying"
+ "fieldtype": "Section Break"
},
{
"doctype": "DocField",
@@ -332,7 +330,6 @@
},
{
"default": "Supplier Name",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Supplier Master created by ",
"fieldname": "supp_master_name",
@@ -340,14 +337,13 @@
"options": "Supplier Name\nNaming Series"
},
{
+ "doctype": "DocField",
"width": "50%",
"fieldname": "column_break6",
- "fieldtype": "Column Break",
- "doctype": "DocField"
+ "fieldtype": "Column Break"
},
{
"default": "No",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Purchase Order Required",
"fieldname": "po_required",
@@ -356,7 +352,6 @@
},
{
"default": "No",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Purchase Receipt Required",
"fieldname": "pr_required",
@@ -365,9 +360,9 @@
},
{
"doctype": "DocField",
+ "label": "Maintain same rate throughout purchase cycle",
"fieldname": "maintain_same_rate",
- "fieldtype": "Check",
- "label": "Maintain same rate throughout purchase cycle"
+ "fieldtype": "Check"
},
{
"doctype": "DocField",
@@ -378,7 +373,6 @@
},
{
"description": "Employee record is created using selected field. ",
- "colour": "White:FFF",
"doctype": "DocField",
"label": "Employee Records to be created by ",
"fieldname": "emp_created_by",
@@ -387,15 +381,15 @@
},
{
"doctype": "DocField",
+ "label": "System",
"fieldname": "system",
- "fieldtype": "Section Break",
- "label": "System"
+ "fieldtype": "Section Break"
},
{
"doctype": "DocField",
+ "label": "SMS Sender Name",
"fieldname": "sms_sender_name",
- "fieldtype": "Data",
- "label": "SMS Sender Name"
+ "fieldtype": "Data"
},
{
"amend": 0,
@@ -415,20 +409,20 @@
"permlevel": 0
},
{
+ "doctype": "DocPerm",
+ "write": 1,
+ "role": "System Manager",
+ "permlevel": 1
+ },
+ {
+ "doctype": "DocPerm",
"role": "All",
- "permlevel": 1,
- "doctype": "DocPerm"
+ "permlevel": 1
},
{
+ "doctype": "DocPerm",
"write": 1,
"role": "System Manager",
- "permlevel": 1,
- "doctype": "DocPerm"
- },
- {
- "write": 1,
- "role": "System Manager",
- "permlevel": 2,
- "doctype": "DocPerm"
+ "permlevel": 2
}
]
\ No newline at end of file
diff --git a/setup/doctype/item_group/item_group.js b/setup/doctype/item_group/item_group.js
index 3869eec00b..db894fa9d6 100644
--- a/setup/doctype/item_group/item_group.js
+++ b/setup/doctype/item_group/item_group.js
@@ -14,6 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+ cur_frm.cscript.set_root_readonly(doc);
+}
+
+cur_frm.cscript.set_root_readonly = function(doc) {
+ // read-only for root item group
+ if(!doc.parent_item_group) {
+ cur_frm.perm = [[1,0,0], [1,0,0]];
+ cur_frm.set_intro("This is a root item group and cannot be edited.");
+ } else {
+ cur_frm.set_intro(null);
+ }
+}
+
//get query select item group
cur_frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.`is_group` = "Yes" AND `tabItem Group`.`docstatus`!= 2 AND `tabItem Group`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` ASC LIMIT 50';
diff --git a/setup/doctype/sales_partner/sales_partner.js b/setup/doctype/sales_partner/sales_partner.js
index f5c084da38..a0f138c5a4 100644
--- a/setup/doctype/sales_partner/sales_partner.js
+++ b/setup/doctype/sales_partner/sales_partner.js
@@ -77,7 +77,7 @@ cur_frm.cscript.make_contact = function() {
page_length: 2,
new_doctype: "Contact",
custom_new_doc: function(doctype) {
- var contact = LocalDB.create('Contact');
+ var contact = wn.model.make_new_doc_and_get_name('Contact');
contact = locals['Contact'][contact];
contact.sales_partner = cur_frm.doc.name;
wn.set_route("Form", "Contact", contact.name);
diff --git a/setup/doctype/sales_person/sales_person.js b/setup/doctype/sales_person/sales_person.js
index ba1a339ad2..c52948803f 100644
--- a/setup/doctype/sales_person/sales_person.js
+++ b/setup/doctype/sales_person/sales_person.js
@@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root
- if(doc.name==='All Sales Persons') {
+ if(!doc.parent_sales_person) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root sales person and cannot be edited.");
} else {
diff --git a/setup/doctype/sales_person/sales_person.py b/setup/doctype/sales_person/sales_person.py
index 41d5042945..943e724c9b 100644
--- a/setup/doctype/sales_person/sales_person.py
+++ b/setup/doctype/sales_person/sales_person.py
@@ -33,3 +33,6 @@ class DocType(DocTypeNestedSet):
if not flt(d.target_qty) and not flt(d.target_amount):
webnotes.msgprint("Either target qty or target amount is mandatory.")
raise Exception
+
+ super(DocType, self).validate()
+
\ No newline at end of file
diff --git a/setup/doctype/territory/territory.js b/setup/doctype/territory/territory.js
index a04bea384f..2932006013 100644
--- a/setup/doctype/territory/territory.js
+++ b/setup/doctype/territory/territory.js
@@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root territory
- if(doc.name==='All Territories') {
+ if(!doc.parent_territory) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root territory and cannot be edited.");
} else {
@@ -28,12 +28,6 @@ cur_frm.cscript.set_root_readonly = function(doc) {
}
}
-
-cur_frm.cscript.onload = function(){
-
-}
-
-
//get query select territory
cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "Yes" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.`name` !="'+doc.territory_name+'" AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
diff --git a/setup/doctype/territory/territory.py b/setup/doctype/territory/territory.py
index 59c0b3a5d4..4b6468e663 100644
--- a/setup/doctype/territory/territory.py
+++ b/setup/doctype/territory/territory.py
@@ -33,3 +33,6 @@ class DocType(DocTypeNestedSet):
if not flt(d.target_qty) and not flt(d.target_amount):
msgprint("Either target qty or target amount is mandatory.")
raise Exception
+
+ super(DocType, self).validate()
+
\ No newline at end of file
diff --git a/setup/doctype/workflow_rule/workflow_rule.js b/setup/doctype/workflow_rule/workflow_rule.js
index 9fb2013483..a506101894 100644
--- a/setup/doctype/workflow_rule/workflow_rule.js
+++ b/setup/doctype/workflow_rule/workflow_rule.js
@@ -32,7 +32,7 @@ cur_frm.cscript.select_form = function(doc, cdt, cdn){
var mydoc = doc
var call_back_action = function(mydoc){
- $c('runserverobj', args={'method':'field_label_list', 'docs':compress_doclist (make_doclist (mydoc.doctype,mydoc.name))},
+ $c('runserverobj', args={'method':'field_label_list', 'docs':wn.model.compress (make_doclist (mydoc.doctype,mydoc.name))},
function(r, rt) {
var doc = locals[mydoc.doctype][mydoc.name];
cur_frm.fields_dict.workflow_action_details.grid.get_field("action_field").df.options = r.message;
@@ -41,7 +41,7 @@ cur_frm.cscript.select_form = function(doc, cdt, cdn){
}
var call_back_rule = function(mydoc){
- $c('runserverobj', args={'method':'compare_field', 'docs':compress_doclist (make_doclist (mydoc.doctype,mydoc.name))},
+ $c('runserverobj', args={'method':'compare_field', 'docs':wn.model.compress (make_doclist (mydoc.doctype,mydoc.name))},
function(r, rt) {
var doc = locals[mydoc.doctype][mydoc.name];
cur_frm.fields_dict.workflow_rule_details.grid.get_field("comparing_field").df.options = r.message;
@@ -50,7 +50,7 @@ cur_frm.cscript.select_form = function(doc, cdt, cdn){
);
}
- $c('runserverobj', args={'method':'maindoc_field', 'docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
+ $c('runserverobj', args={'method':'maindoc_field', 'docs':wn.model.compress (make_doclist (doc.doctype,doc.name))},
function(r, rt) {
var doc = locals[mydoc.doctype][mydoc.name];
cur_frm.fields_dict.workflow_rule_details.grid.get_field("rule_field").df.options = r.message;
diff --git a/setup/page/permission_engine/permission_engine.html b/setup/page/permission_engine/permission_engine.html
index 7831447a6a..8d989586c3 100644
--- a/setup/page/permission_engine/permission_engine.html
+++ b/setup/page/permission_engine/permission_engine.html
@@ -5,4 +5,6 @@
One of the Roles has Submit permission.
You will have to Cancel and then Amend a submitted Document for making changes.
+
+Note: A document is not accessible to a user if Permission at level 0 is not given.
diff --git a/startup/event_handlers.py b/startup/event_handlers.py
index 9cd1af94d4..4808298368 100644
--- a/startup/event_handlers.py
+++ b/startup/event_handlers.py
@@ -25,14 +25,10 @@ def on_login_post_session(login_manager):
update login_from and delete parallel sessions
"""
# Clear previous sessions i.e. logout previous log-in attempts
- exception_list = ['demo@erpnext.com', 'Administrator', 'Guest']
- if webnotes.session['user'] not in exception_list:
- sid_list = webnotes.conn.sql("""
- DELETE FROM `tabSessions`
- WHERE
- user=%s AND
- sid!=%s""", \
- (webnotes.session['user'], webnotes.session['sid']), as_list=1)
+ allow_multiple_sessions = ['demo@erpnext.com', 'Administrator', 'Guest']
+ if webnotes.session['user'] not in allow_multiple_sessions:
+ from webnotes.sessions import clear_sessions
+ clear_sessions(webnotes.session.user, keep_current=True)
# check if account is expired
check_if_expired()
@@ -119,7 +115,7 @@ def check_if_expired():
from webnotes.utils import formatdate
msg = """Oops! Your subscription expired on %s.
""" % formatdate(conf.expires_on)
- if 'System Manager' in webnotes.user.roles:
+ if 'System Manager' in webnotes.user.get_roles():
msg += """Just drop in a mail at support@erpnext.com and
we will guide you to get your account re-activated."""
else:
diff --git a/startup/startup.py b/startup/startup.py
index 828239ee15..15ea491b13 100644
--- a/startup/startup.py
+++ b/startup/startup.py
@@ -48,7 +48,7 @@ def get_things_todo():
incomplete_todos = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabToDo`
WHERE IFNULL(checked, 0) = 0
- AND owner = %s""", webnotes.session.get('user'))
+ AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
return incomplete_todos and cint(incomplete_todos[0][0]) or 0
def get_todays_events():
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index 837d52c7a3..a80966aaa4 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -128,7 +128,7 @@ cur_frm.cscript.get_items = function(doc,dt,dn) {
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
- tn = createLocal('Contact');
+ tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_customer = 1;
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
loaddoc('Contact', tn);
@@ -192,9 +192,9 @@ cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
//-----------------------------------Make Sales Invoice----------------------------------------------
cur_frm.cscript['Make Sales Invoice'] = function() {
var doc = cur_frm.doc
- n = createLocal('Sales Invoice');
+ n = wn.model.make_new_doc_and_get_name('Sales Invoice');
$c('dt_map', args={
- 'docs':compress_doclist([locals['Sales Invoice'][n]]),
+ 'docs':wn.model.compress([locals['Sales Invoice'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Sales Invoice',
'from_docname':doc.name,
@@ -209,9 +209,9 @@ cur_frm.cscript['Make Sales Invoice'] = function() {
cur_frm.cscript['Make Installation Note'] = function() {
var doc = cur_frm.doc;
if(doc.per_installed < 99.99){
- n = createLocal('Installation Note');
+ n = wn.model.make_new_doc_and_get_name('Installation Note');
$c('dt_map', args={
- 'docs':compress_doclist([locals['Installation Note'][n]]),
+ 'docs':wn.model.compress([locals['Installation Note'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Installation Note',
'from_docname':doc.name,
@@ -228,9 +228,9 @@ cur_frm.cscript['Make Installation Note'] = function() {
//-----------------------------------Make Sales Invoice----------------------------------------------
cur_frm.cscript['Make Packing Slip'] = function() {
var doc = cur_frm.doc
- n = createLocal('Packing Slip');
+ n = wn.model.make_new_doc_and_get_name('Packing Slip');
$c('dt_map', args={
- 'docs':compress_doclist([locals['Packing Slip'][n]]),
+ 'docs':wn.model.compress([locals['Packing Slip'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Packing Slip',
'from_docname':doc.name,
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js
index d26636e253..23aa2cc951 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -24,7 +24,7 @@ wn.require('app/utilities/doctype/sms_control/sms_control.js');
//========================== On Load ================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
- if(!doc.fiscal_year && doc.__islocal){ set_default_values(doc);}
+ if(!doc.fiscal_year && doc.__islocal){ wn.model.set_default_values(doc);}
if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date());
if (!doc.status) doc.status = 'Draft';
@@ -107,7 +107,7 @@ cur_frm.cscript.pull_purchase_order_details = function(doc, dt, dn) {
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
- tn = createLocal('Contact');
+ tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_supplier = 1;
if(doc.supplier) locals['Contact'][tn].supplier = doc.supplier;
loaddoc('Contact', tn);
@@ -150,9 +150,10 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn)
cur_frm.cscript.received_qty = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
ret = {
- 'qty' : 0,
+ 'qty' : (flt(d.qty) && flt(d.qty) < flt(d.received_qty))
+ ? flt(d.qty) : flt(d.received_qty),
'stock_qty': 0,
- 'rejected_qty' : 0
+ 'rejected_qty' : 0,
}
set_multiple('Purchase Receipt Item', cdn, ret, 'purchase_receipt_details');
cur_frm.cscript.calc_amount(doc, 2);
@@ -240,9 +241,9 @@ cur_frm.fields_dict.purchase_receipt_details.grid.get_field("qa_no").get_query =
// ================================ Make Purchase Invoice ==========================================
cur_frm.cscript['Make Purchase Invoice'] = function() {
- n = createLocal('Purchase Invoice');
+ n = wn.model.make_new_doc_and_get_name('Purchase Invoice');
$c('dt_map', args={
- 'docs':compress_doclist([locals['Purchase Invoice'][n]]),
+ 'docs':wn.model.compress([locals['Purchase Invoice'][n]]),
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Purchase Invoice',
'from_docname': cur_frm.doc.name,
diff --git a/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js b/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js
index d57ff5dd77..7547b6a0dc 100644
--- a/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js
+++ b/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js
@@ -120,7 +120,7 @@ cur_frm.cscript.validate_returned_qty = function(cl) {
// map parent fields of stock entry
//----------------------------------
cur_frm.cscript.map_parent_fields = function(doc, cdt, cdn) {
- var se = LocalDB.create('Stock Entry');
+ var se = wn.model.make_new_doc_and_get_name('Stock Entry');
se = locals['Stock Entry'][se];
se.posting_date = dateutil.obj_to_str(new Date());
se.transfer_date = dateutil.obj_to_str(new Date());
@@ -148,7 +148,7 @@ cur_frm.cscript.map_parent_fields = function(doc, cdt, cdn) {
cur_frm.cscript.map_child_fields = function(cl, se) {
for(var i = 0; i