Search code examples
pythonodoo-10

UnboundLocalError: local variable 'connector' referenced before assignment


I have a error : UnboundLocalError: local variable 'connector' referenced before assignment. To self host, etc. I have declaration in my init.

class OdooUtility():
  connector = None
  driver = None

  def get_control(self):        
    try:
        connector= ODOO(self.host, port=self.port)
        connector.login(self.dbname, self.username, self.password)
    except Exception as e:
        print e.message

    control = connector.env['rm.control']
    control_ids = control.search([])
    c = control.browse(control_ids)
    res = []
    for row in c:
        res.append(row)
    return res

How can I fix this? Thanks for any help!


Solution

  • You either need to write self.connector or OdooUtility.connector instead of just connector. I suspect self.connector is what you wanted.