Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait 2012-10-05 12:12:08 +05:30
commit 976f9eeab7
3 changed files with 12 additions and 36 deletions

View File

@ -127,7 +127,7 @@ erpnext.module_page.hide_links = function(wrapper) {
// pages
$(wrapper).find('[data-role]').each(function() {
// can define multiple roles
var data_roles = $(this).attr("data-role").split(",").map(function(role) {
var data_roles = $.map($(this).attr("data-role").split(","), function(role) {
return role.trim(); });
if(!has_common(user_roles, ["System Manager"].concat(data_roles))) {
var html = $(this).html();

View File

@ -52,9 +52,9 @@ class DocType:
# update prices in Price List
def update_prices(self):
from core.page.data_import_tool.data_import_tool import read_csv_content
from webnotes.utils.datautils import read_csv_content_from_attached_file
data = read_csv_content_from_attached_file(self.doc)
data = read_csv_content(self.get_csv_data())
webnotes.conn.auto_commit_on_many_writes = 1
updated = 0
@ -85,21 +85,4 @@ class DocType:
msgprint("[Ignored] Did not find Item '%s'" % line[1])
msgprint("<b>%s</b> items updated" % updated)
webnotes.conn.auto_commit_on_many_writes = 0
# Update CSV data
def get_csv_data(self):
if not self.doc.file_list:
msgprint("File not attached!")
raise Exception
fid = self.doc.file_list.split(',')[1]
try:
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
except Exception, e:
webnotes.msgprint("Unable to open attached file. Please try again.")
raise e
return content
webnotes.conn.auto_commit_on_many_writes = 0

View File

@ -38,19 +38,16 @@ class DocType:
return [['Item Code', 'Warehouse', 'Quantity', 'Incoming Rate']]
def get_csv_file_data(self, submit = 1):
def read_csv_content(self, submit = 1):
"""Get csv data"""
if submit:
filename = self.doc.file_list.split(',')
if not filename:
msgprint("Please Attach File. ", raise_exception=1)
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
from webnotes.utils.datautils import read_csv_content_from_attached_file
data = read_csv_content_from_attached_file(self.doc)
else:
content = self.doc.diff_info
from webnotes.utils.datautils import read_csv_content
data = read_csv_content(self.doc.diff_info)
return content
return data
def convert_into_list(self, data, submit = 1):
"""Convert csv data into list"""
@ -76,15 +73,11 @@ class DocType:
raise Exception
def get_reconciliation_data(self,submit = 1):
def get_reconciliation_data(self, submit = 1):
"""Read and validate csv data"""
import csv
from core.page.data_import_tool.data_import_tool import read_csv_content
csv_content = self.get_csv_file_data(submit).encode('utf-8')
data = read_csv_content(csv_content)
data = self.read_csv_content(submit)
self.convert_into_list(data, submit)
def validate_item(self, item, count):
""" Validate item exists and non-serialized"""
det = sql("select item_code, has_serial_no from `tabItem` where name = %s", cstr(item), as_dict = 1)