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

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

View File

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

View File

@@ -52,9 +52,9 @@ class DocType:
# update prices in Price List # update prices in Price List
def update_prices(self): 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 webnotes.conn.auto_commit_on_many_writes = 1
updated = 0 updated = 0
@@ -85,21 +85,4 @@ class DocType:
msgprint("[Ignored] Did not find Item '%s'" % line[1]) msgprint("[Ignored] Did not find Item '%s'" % line[1])
msgprint("<b>%s</b> items updated" % updated) msgprint("<b>%s</b> items updated" % updated)
webnotes.conn.auto_commit_on_many_writes = 0 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

View File

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