fixes in stock reconciliation and price list csv reading
diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py
index fed2768..a88309b 100644
--- a/setup/doctype/price_list/price_list.py
+++ b/setup/doctype/price_list/price_list.py
@@ -52,9 +52,9 @@
# 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 @@
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
\ No newline at end of file
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 4e701d3..74a439f 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -38,19 +38,16 @@
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 @@
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)