Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. import random
  2. import time
  3. import datetime
  4. import odoorpc
  5.  
  6. odoo = odoorpc.ODOO('xxxxxxxxx', port=xxxx)
  7.  
  8. #print('Listado Bases de datos %s' , odoo.db.list())
  9.  
  10. odoo.login('xxxxxxxx', 'POIUWERQE', '%"##"$"#&%$%AASD==')
  11.  
  12. # Current user
  13. user = odoo.env.user
  14. print(user.name)            # name of the user connected
  15. print(user.company_id.name) # the name of its company
  16.  
  17. #Acceso al modelo de datos
  18. medicion = odoo.env['uniquindio.medicion']
  19.  
  20. pruebas = 1
  21.  
  22. while True:
  23.  
  24.     print('Prueba # %s',pruebas)
  25.     inicio =  datetime.datetime.now()
  26.  
  27.     precipitacion = random.randint(100, 200)
  28.     humedad_amb = random.randint(20, 80)
  29.     temp = random.randint(-10, 50)
  30.     humedad = random.randint(10, 100)
  31.  
  32.     medicion.create({'estacion_id':1,'tipo_id':1 , 'valor': humedad , 'unidad': '%'})
  33.     medicion.create({'estacion_id':1,'tipo_id':2 , 'valor': temp , 'unidad': 'Grados Centigrados'})
  34.     medicion.create({'estacion_id':1,'tipo_id':3 , 'valor': humedad_amb , 'unidad': '%'})
  35.     medicion.create({'estacion_id':1,'tipo_id':4 , 'valor': precipitacion , 'unidad': 'cm3'})
  36.    
  37.     fin =  datetime.datetime.now()
  38.  
  39.     print('Tiempo de la Prueba %s (segundos)', (fin-inicio).total_seconds())
  40.  
  41.     pruebas = pruebas + 1
  42.  
  43.     time.sleep(0.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement