From 08ca270b6572119177ff2812499009ce771bc1f7 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 4 Oct 2012 19:26:22 +0530 Subject: [PATCH 1/2] allow export of analytics reports to Report Manager or System Manager --- public/js/modules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/modules.js b/public/js/modules.js index 772a561f72..fb7775e0e1 100644 --- a/public/js/modules.js +++ b/public/js/modules.js @@ -129,7 +129,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(); From 727643210cfed7a3bfd639b3f7c8689559cdbb81 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 5 Oct 2012 11:38:06 +0530 Subject: [PATCH 2/2] fixes in stock reconciliation and price list csv reading --- setup/doctype/price_list/price_list.py | 23 +++---------------- .../stock_reconciliation.py | 23 +++++++------------ 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py index fed2768fd1..a88309b6db 100644 --- a/setup/doctype/price_list/price_list.py +++ b/setup/doctype/price_list/price_list.py @@ -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("%s 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 4e701d3c26..74a439f5c2 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -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)