Пример #1
0
 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)
     self.convert_into_list(data, submit)
Пример #2
0
	def update_prices(self):
		from core.page.data_import_tool.data_import_tool import read_csv_content
		
		data = read_csv_content(self.get_csv_data())
		webnotes.conn.auto_commit_on_many_writes = 1
				
		updated = 0
		
		for line in data:
			if line and len(line)==3 and line[0]!='Item':
				# if item exists
				if webnotes.conn.sql("select name from tabItem where name=%s", line[0]):
					if self.is_currency_valid(line[2]):
						# if price exists
						ref_ret_detail = webnotes.conn.sql("select name from `tabItem Price` where parent=%s and price_list_name=%s and ref_currency=%s", \
							(line[0], self.doc.name, line[2]))
						if ref_ret_detail:
							webnotes.conn.sql("update `tabItem Price` set ref_rate=%s where name=%s", (line[1], ref_ret_detail[0][0]))
						else:
							d = Document('Item Price')
							d.parent = line[0]
							d.parentfield = 'ref_rate_details'
							d.parenttype = 'Item'
							d.price_list_name = self.doc.name
							d.ref_rate = line[1]
							d.ref_currency = line[2]
							d.save(1)
						updated += 1
					else:
						msgprint("[Ignored] Unknown currency '%s' for Item '%s'" % (line[2], line[0]))
				else:
					msgprint("[Ignored] Did not find Item '%s'" % line[1])
		
		msgprint("<b>%s</b> items updated" % updated)
		webnotes.conn.auto_commit_on_many_writes = 0
Пример #3
0
	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)
		self.convert_into_list(data, submit)
Пример #4
0
    def update_prices(self):
        from core.page.data_import_tool.data_import_tool import read_csv_content

        data = read_csv_content(self.get_csv_data())
        webnotes.conn.auto_commit_on_many_writes = 1

        updated = 0

        for line in data:
            if line and len(line) == 3 and line[0] != 'Item':
                # if item exists
                if webnotes.conn.sql("select name from tabItem where name=%s",
                                     line[0]):
                    if self.is_currency_valid(line[2]):
                        # if price exists
                        ref_ret_detail = webnotes.conn.sql("select name from `tabItem Price` where parent=%s and price_list_name=%s and ref_currency=%s", \
                         (line[0], self.doc.name, line[2]))
                        if ref_ret_detail:
                            webnotes.conn.sql(
                                "update `tabItem Price` set ref_rate=%s where name=%s",
                                (line[1], ref_ret_detail[0][0]))
                        else:
                            d = Document('Item Price')
                            d.parent = line[0]
                            d.parentfield = 'ref_rate_details'
                            d.parenttype = 'Item'
                            d.price_list_name = self.doc.name
                            d.ref_rate = line[1]
                            d.ref_currency = line[2]
                            d.save(1)
                        updated += 1
                    else:
                        msgprint(
                            "[Ignored] Unknown currency '%s' for Item '%s'" %
                            (line[2], line[0]))
                else:
                    msgprint("[Ignored] Did not find Item '%s'" % line[1])

        msgprint("<b>%s</b> items updated" % updated)
        webnotes.conn.auto_commit_on_many_writes = 0