Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Odoo v15: XMLRPC changed 'get_object_reference' shortcut to '_xmlid_lookup'

Avatar
odoo
Avatar
Discard
2 Answers
0
Avatar
odoo
Best Answer

I found the solution, reviewing the odoo source code I could see that the check_object_reference method does the same thing by calling the _xmlid_lookup method in v15 and in v13 and v14 get_object_reference, so this method would only be called and returns what is desired for all those versions, I will close my question since I found the solution.

Avatar
Discard
0
Avatar
odoo
Best Answer

Hello bro, I needed to do the same thing. Although I'm getting a strange error. When I give two args it says me "3 were given" when I add only one it says "it needs two but 1 were given." how to solve this?


Thanks

1 Comment
Avatar
Discard
Avatar
odoo
-

Hello bro,
in v13 to reference a record stored in the db in odoo via XMLRPC, internally odoo has this method

odoo>addons>base>models>ir_model.py line:1728 - 1744

@api.model
def get_object_reference(self, module, xml_id):
"""Returns (model, res_id) corresponding to a given module and xml_id (cached) or raise ValueError if not found"""
return self.xmlid_lookup("%s.%s" % (module, xml_id))[1:3]

which one can call internally via a module like this:

self.env['ir.model.data'].get_object_reference('base_setup', 'action_general_configuration')

with XMLRPC I can call it like this by calling the method that wraps the other called method (check_object_reference) and sending this data

from xmlrpc import client as xmlrpclib
xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format('url')).execute_kw(db, uid, password,
'ir.model.data', 'check_object_reference',
['base', 'user_admin']
)
note: if you want to search for a xml record like 'base.user_admin' you have to send it separately --> 'base', 'user_admin'

which would give you an output in an array with a dictionary of the id number and the model
example: [(1, 'res.partner')] - something like this

I hope my explanation has helped you, if you still have problems tell me the source code maybe it will solve it