Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/page/accounts_home/accounts_home.html b/accounts/page/accounts_home/accounts_home.html
index 3a6f2b8..db87a49 100644
--- a/accounts/page/accounts_home/accounts_home.html
+++ b/accounts/page/accounts_home/accounts_home.html
@@ -12,7 +12,7 @@
<p class="help">Bills raised by Suppliers</p>
</div>
<div style="width: 48%; float: right;">
- <h4><a href="#!Accounts Browser/Account">Chart of Accounts</a></h4>
+ <h4><a href="#!Accounts Browser/Account" data-role="Accounts Manager, Accounts User">Chart of Accounts</a></h4>
<p class="help">Structure of books of accounts</p>
<br>
<h4><a href="#!Accounts Browser/Cost Center">Chart of Cost Centers</a></h4>
@@ -74,7 +74,7 @@
href="#!Financial Statements">Financial Statements</a>
</div>
<div class="section-item">
- <a class="section-link"
+ <a class="section-link" data-role="Accounts Manager"
title = "Import Multiple Vouchers from CSV"
href="#voucher-import-tool">Voucher Import Tool</a>
</div>
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index 8e71151..3815578 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -22,11 +22,4 @@
$('.india-specific').toggle(false);
}
- if(wn.boot.profile.roles.indexOf('Accounts Manager')==-1 && wn.boot.profile.roles.indexOf('Accounts User')==-1) {
- $('[href*="Accounts Browser"]').each(function() {
- var txt = $(this).text();
- $(this).parent().css('color', '#999').html(txt);
- });
- }
-
}
diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py
index b8dd717..7cff10f 100644
--- a/accounts/page/voucher_import_tool/voucher_import_tool.py
+++ b/accounts/page/voucher_import_tool/voucher_import_tool.py
@@ -35,12 +35,12 @@
rows = read_csv_content_from_uploaded_file()
common_values = get_common_values(rows)
- data = get_data(rows)
+ data, start_idx = get_data(rows)
if rows[0][0]=="Voucher Import :Single":
- return import_single(common_values, data)
+ return import_single(common_values, data, start_idx)
else:
- return import_multiple(common_values, data)
+ return import_multiple(common_values, data, start_idx)
def map_fields(field_list, source, target):
for f in field_list:
@@ -49,12 +49,12 @@
else:
target[f] = source.get(f)
-def import_multiple(common_values, data):
+def import_multiple(common_values, data, start_idx):
from webnotes.model.doc import Document
from webnotes.model.doclist import DocList
from webnotes.model.code import get_obj
- from accounts.utils import get_fiscal_year_from_date
- from webnotes.utils.dateutils import user_to_str
+ from accounts.utils import get_fiscal_year
+ from webnotes.utils.dateutils import parse_date
messages = []
@@ -82,17 +82,17 @@
jv = webnotes.DictObj()
try:
- d.posting_date = user_to_str(d.posting_date)
- d.due_date = user_to_str(d.due_date)
- d.ref_date = user_to_str(d.ref_date)
+ d.posting_date = parse_date(d.posting_date)
+ d.due_date = parse_date(d.due_date)
+ d.ref_date = parse_date(d.ref_date)
d.company = common_values.company
jv = Document("Journal Voucher")
map_fields(["voucher_type", "posting_date", "naming_series", "remarks:remark",
- "ref_no:cheque_no", "ref_date:cheque_date", "is_opening",
+ "ref_number:cheque_no", "ref_date:cheque_date", "is_opening",
"amount:total_debit", "amount:total_credit", "due_date", "company"], d, jv.fields)
- jv.fiscal_year = get_fiscal_year_from_date(jv.posting_date)
+ jv.fiscal_year = get_fiscal_year(jv.posting_date)[0]
detail1 = Document("Journal Voucher Detail")
detail1.parent = True
@@ -112,13 +112,15 @@
doclist.submit()
webnotes.conn.commit()
- messages.append("<p style='color: green'>[row #%s] %s imported</p>" \
- % (i, jv.name))
+ messages.append("""<p style='color: green'>[row #%s]
+ <a href=\"#Form/Journal Voucher/%s\">%s</a> imported</p>""" \
+ % ((start_idx + 1) + i, jv.name, jv.name))
except Exception, e:
webnotes.conn.rollback()
+ err_msg = webnotes.message_log and webnotes.message_log[0] or unicode(e)
messages.append("<p style='color: red'>[row #%s] %s failed: %s</p>" \
- % (i, jv.name, webnotes.message_log and webnotes.message_log[0] or "No message"))
+ % ((start_idx + 1) + i, jv.name, err_msg or "No message"))
webnotes.errprint(webnotes.getTraceback())
webnotes.message_log = []
@@ -142,11 +144,13 @@
def get_data(rows):
start_row = 0
data = []
+ start_row_idx = 0
for i in xrange(len(rows)):
r = rows[i]
if r[0]:
if start_row and i >= start_row:
+ if not start_row_idx: start_row_idx = i
d = webnotes.DictObj()
for cidx in xrange(len(columns)):
d[columns[cidx]] = r[cidx]
@@ -155,7 +159,8 @@
if r[0]=="--------Data----------":
start_row = i+2
columns = [c.replace(" ", "_").lower() for c in rows[i+1]]
- return data
+
+ return data, start_row_idx
@webnotes.whitelist()
def get_template_single():
diff --git a/public/js/modules.js b/public/js/modules.js
index a9e82d6..9b554e9 100644
--- a/public/js/modules.js
+++ b/public/js/modules.js
@@ -128,7 +128,10 @@
// pages
$(wrapper).find('[data-role]').each(function() {
- if(!has_common(user_roles, [$(this).attr("data-role"), "System Manager"])) {
+ // can define multiple roles
+ var data_roles = $(this).attr("data-role").split(",").map(function(role) {
+ return role.trim(); });
+ if(!has_common(user_roles, ["System Manager"].concat(data_roles))) {
var html = $(this).html();
$(this).parent().css('color', '#999');
$(this).replaceWith('<span title="Only accessible by Roles: '+
diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py
index d0a715d..d50a348 100644
--- a/selling/doctype/lead/lead.py
+++ b/selling/doctype/lead/lead.py
@@ -67,7 +67,6 @@
return ret
def validate(self):
- import string
if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason:
msgprint("Please Enter Lost Reason under More Info section")
raise Exception
@@ -80,7 +79,6 @@
if not validate_email_add(self.doc.email_id):
msgprint('Please enter valid email id.')
raise Exception
-
def on_update(self):
if self.doc.contact_date: