← Back to team overview

openupgrade-drivers team mailing list archive

Re: [Question #226718]: Openupgrade Comparions Config: problem with connection

 

Question #226718 on OpenUpgrade Server changed:
https://answers.launchpad.net/openupgrade-server/+question/226718

Jeroen_monkeytail posted a new comment:
In
/openupgrade/6.0/bin/addons/openupgrade_records/model/comparison_config.py

The code is:

    def test_connection(self, cr, uid, ids, context=None):
        try:
            connection = self.get_connection(cr, uid, [ids[0]], context)
            print 'connection: ', connection
            user_model = connection.get_model("res.users")
            print 'user_model: ', user_model
            ids = user_model.search([("login", "=", "admin")])#ids = user_model.search([("login", "=", "admin")])
            print 'ids: ', ids
            user_info = user_model.read(ids[0], ["name"])
            print 'user_info: ', user_info
        except Exception, e:
            raise osv.except_osv(
                _("Connection failed."), unicode(e))
        raise osv.except_osv(
            _("Connection succesful."),
            _("%s is connected.") % user_info["name"]
            )

the result is:
connection:  <openerplib.main.Connection object at 0x2418050>
user_model:  <openerplib.main.Model object at 0x2418090>
for 'ids' there is no value printed, so something goes wrong with  user_model.search_read

If i analyse the openerplib module in the ubuntu terminal, I see:

>>> import openerplib as p

>>> dir(p.main.Model)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'search_read']

>>> p.main.Model.search([("login", "=", "admin")])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'Model' has no attribute 'search'

there is a function, called search_read, however when we use this, we
also get an error:

>>> p.main.Model.search_read([("login", "=", "admin")])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method search_read() must be called with Model instance as first argument (got list instance instead)

-- 
You received this question notification because you are a member of
OpenUpgrade Drivers, which is an answer contact for OpenUpgrade Server.