def do_query(self, cr, uid, ids, context=None): for job in self.browse(cr, uid, ids): oer_local = openerplib.get_connection( hostname="localhost", port=job.local_server_id.port, database=cr.dbname, login=job.local_server_id.login, password=job.local_server_id.password) etl = oer_etl(oer_local) result = "" rows = etl.get_rows(job.id) for i, row in enumerate(rows): if i == 0: for r in row: result += r + " | " result = result and result[:-3] + '\n' or '\n' for r in row: if type(row[r]) is unicode or type(row[r]) is str: result += row[r] + " | " else: result += str(row[r]) + " | " result = result and result[:-3] + '\n' or '\n' if job.query_result_size and i > job.query_result_size: result += '...\n' break result += "(%s rows retrieved)" % len(rows) if job.query_encoding and type(result) is not unicode: result = result.decode(job.query_encoding) self.write(cr, uid, [job.id], {'query_result': result}, context=context) return True
def do_query(self, cr, uid, ids, context=None): for job in self.browse(cr, uid, ids): oer_local = openerplib.get_connection(hostname="localhost", port=job.local_server_id.port, database=cr.dbname, login=job.local_server_id.login, password=job.local_server_id.password) etl = oer_etl(oer_local) result = "" rows = etl.get_rows(job.id) for i, row in enumerate(rows): if i == 0: for r in row: result += r + " | " result = result and result[:-3] + '\n' or '\n' for r in row: if type(row[r]) is unicode or type(row[r]) is str: result += row[r] + " | " else: result += str(row[r]) + " | " result = result and result[:-3] + '\n' or '\n' if job.query_result_size and i > job.query_result_size: result += '...\n' break result += "(%s rows retrieved)"%len(rows) if job.query_encoding and type(result) is not unicode: result = result.decode(job.query_encoding) self.write(cr, uid, [job.id], {'query_result': result}, context=context) return True
def load(self, cr, uid, ids): for job in self.browse(cr, uid, ids): oer_local = openerplib.get_connection(hostname="localhost", port=job.local_server_id.port, database=cr.dbname, login=job.local_server_id.login, password=job.local_server_id.password) etl = oer_etl(oer_local) for row in etl.get_rows(job.id): new_id = etl.create(job.id, etl.get_values(job.id,row), pk=row.get('pk',False)) self.action_done(cr, uid, ids) return True
def run(hostname,port,database,login,password,log_print=True): oer_local = openerplib.get_connection(hostname=hostname, port=port, database=database, login=login, password=password) etl = oer_etl(oer_local, log_print=log_print) for job in etl.get_jobs(): if etl.get_job_state(job['id']) != 'ready': continue oer_local.get_model('etl.job').action_start([job['id']]) for row in etl.get_rows(job['id']): new_id = etl.create(job['id'], etl.get_values(job['id'],row), pk=row.get('pk',False)) oer_local.get_model('etl.job').action_done([job['id']]) print "Finish etl_cron"
def load(self, cr, uid, ids): for job in self.browse(cr, uid, ids): oer_local = openerplib.get_connection( hostname="localhost", port=job.local_server_id.port, database=cr.dbname, login=job.local_server_id.login, password=job.local_server_id.password) etl = oer_etl(oer_local) for row in etl.get_rows(job.id): new_id = etl.create(job.id, etl.get_values(job.id, row), pk=row.get('pk', False)) self.action_done(cr, uid, ids) return True
def run(hostname, port, database, login, password, log_print=True): oer_local = openerplib.get_connection(hostname=hostname, port=port, database=database, login=login, password=password) etl = oer_etl(oer_local, log_print=log_print) for job in etl.get_jobs(): if etl.get_job_state(job['id']) != 'ready': continue oer_local.get_model('etl.job').action_start([job['id']]) for row in etl.get_rows(job['id']): new_id = etl.create(job['id'], etl.get_values(job['id'], row), pk=row.get('pk', False)) oer_local.get_model('etl.job').action_done([job['id']]) print "Finish etl_cron"