Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. class NebizImportManufOrders(models.Model):
  2. _inherit = 'mrp.production'
  3. _name = 'mrp.production'
  4. erp7_id = fields.Integer("ERP7 ID", default=0)
  5.  
  6. def get_rows_fromdb(self):
  7. db_vals = self.env['db.config'].get_db_config()
  8. if db_vals:
  9. table = 'mrp_production'
  10. limit = 9999
  11. import psycopg2
  12. conn = psycopg2.connect(database=db_vals['db_name'], user=db_vals['user'], password=db_vals['password'],
  13. host=db_vals['host'], port=db_vals['port'])
  14. if conn:
  15. cur = conn.cursor()
  16. # if limit is None:
  17. # limit = 999999
  18.  
  19. cur.execute("select row_to_json(%s) from %s limit %r;" % (table, table, limit))
  20. rows = cur.fetchall()
  21. cur.close()
  22. return rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement