Python odoo数据库中的xmlrpc搜索

Python odoo数据库中的xmlrpc搜索,python,postgresql,odoo,xml-rpc,Python,Postgresql,Odoo,Xml Rpc,我正在使用xmlrpc搜索我的postgres odoo数据库中的数据 在表中搜索时,所有内容都很好 现在我想在res_partner_title中搜索,但它不会返回ID 我的数据库内容: myDatabase=# select * from res_partner_title; id | create_uid | create_date | name | shortcut | write_uid | write_date

我正在使用xmlrpc搜索我的postgres odoo数据库中的数据

在表中搜索时,所有内容都很好

现在我想在res_partner_title中搜索,但它不会返回ID

我的数据库内容:

myDatabase=# select * from res_partner_title;

id | create_uid |        create_date         |   name    | shortcut | write_uid |         write_date         
----+------------+----------------------------+-----------+----------+-----------+----------------------------
 1 |          1 | 2017-12-29 09:26:11.139936 | Madam     | Mrs.     |         1 | 2017-12-29 09:26:11.139936
 2 |          1 | 2017-12-29 09:26:11.139936 | Miss      | Miss     |         1 | 2017-12-29 09:26:11.139936
 3 |          1 | 2017-12-29 09:26:11.139936 | Sir       | Sr.      |         1 | 2017-12-29 09:26:11.139936
 4 |          1 | 2017-12-29 09:26:11.139936 | Mister    | Mr.      |         1 | 2017-12-29 09:26:11.139936
 5 |          1 | 2017-12-29 09:26:11.139936 | Doctor    | Dr.      |         1 | 2017-12-29 09:26:11.139936
 6 |          1 | 2017-12-29 09:26:11.139936 | Professor | Prof.    |         1 | 2017-12-29 09:26:11.139936
(6 rows)
我的代码:

 myData = myObject.search('res.partner.title', [('shortcut','=','Mr.')])

class MyClass:
def __init__(self, host, port, username, pwd, dbname, context, dbsuperpwd=None,
             dbuser=None, dbpasswd=None):

    self.sock_common = xmlrpclib.ServerProxy ("http://" + host + ":" + str(port) + "/xmlrpc/common")
    self.uid = self.sock_common.login(dbname, username, pwd)    
    self.sock = xmlrpclib.ServerProxy("http://" + host + ":" + str(port) + "/xmlrpc/object")
    self.dbname = dbname
    self.pwd = pwd
    self.dbsuperpwd = dbsuperpwd
    self.context = context



def search(self, modelname, query, offset=0, limit=0, order=False,
           context=None):
    context = context or self.context


    for i in range(MAX_RETRIES):
        try:
            return self.sock.execute(self.dbname, self.uid, self.pwd,
                                     modelname, 'search', query, offset,
                                     limit, order, context)
        except socket.error:
            pass
无论过滤器是什么,它总是返回1

在我的例子中,我如何得到3

编辑添加注释数据

上下文={'lang':'es_es'}

它返回1或0


我刚刚发现,它在odoo9中工作,在odoo10中失败。我想问题可能是语言。您正在上下文中发送电子邮件并查找英文版本的shorcut,因此现在请尝试将当前搜索域替换为['shortcut'、'ilike'、'%Sr.%]

请看ir_翻译表:


修改您的域,将此作为查询参数发送:['shortcut','ilike','%Mr.%]。你也有身份证吗?你能把你发送给搜索的变量上下文的内容粘贴到这里吗?用你的建议编辑我已经给你发了一个答案,但奇怪的是你说你的代码在v9上工作,而不是在v10上,看一看,告诉我你得到了什么。谢谢,问题是odoo版本,我用手动更新了我的代码,它工作正常。我的线索是响应格式,它返回0而不是[0]
  id  | lang  |  src   |            name            | type  | module |   state    | comments | value | res_id 
------+-------+--------+----------------------------+-------+--------+------------+----------+-------+--------
 6483 | es_ES | Mister | res.partner.title,name     | model | base   | translated |          | Señor |      3
 6559 | es_ES | Mr.    | res.partner.title,shortcut | model | base   | translated |          | Sr.   |      3