OCA / odoorpc

Python module to pilot your Odoo servers through JSON-RPC.
http://pythonhosted.org/OdooRPC/
GNU Lesser General Public License v3.0
231 stars 123 forks source link

Issue with odoo.env.ref('base.lang_en') example with Server 15 #68

Closed zobbo closed 1 year ago

zobbo commented 2 years ago

v 0.8.0 of odoorpc, server community edition 15.0

trying to get records with external ids and following the example in the docs - I get the following:

>>> odoo = odoorpc.ODOO('localhost', port=8069)
>>> odoo.login('odoo-dev','admin', 'admin')
>>> lang_en = odoo.env.ref('base.lang_en')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ian/.virtualenvs/odoo-dev/lib/python3.7/site-packages/odoorpc/env.py", line 178, in ref
    'ir.model.data', 'xmlid_to_res_model_res_id', xml_id, True
  File "/Users/ian/.virtualenvs/odoo-dev/lib/python3.7/site-packages/odoorpc/odoo.py", line 431, in execute
    {'service': 'object', 'method': 'execute', 'args': args_to_send},
  File "/Users/ian/.virtualenvs/odoo-dev/lib/python3.7/site-packages/odoorpc/odoo.py", line 274, in json
    data['error']['data']['message'], data['error']
odoorpc.error.RPCError: type object 'ir.model.data' has no attribute 'xmlid_to_res_model_res_id'
>>>
matt454357 commented 2 years ago

That's because 15.0 renamed the function from "xmlid_to_res_model_res_id" to "_xmlid_to_res_model_res_id".

I tried changing the function here: https://github.com/OCA/odoorpc/blob/e0b959bbacac94bcdcaba2bfc8ef66bd3fc75109/odoorpc/env.py#L177-L179 But, of course, "Private methods (such as _xmlid_to_res_model_res_id) cannot be called remotely".

Anyone have a simple workaround, I mean other than the following?

ref_id = rpc.env['ir.model.data'].search([('module', '=', 'base'), ('name', '=', 'lang_en')])
lang_id = rpc.env['ir.model.data'].browse(ref_id).res_id
pedrobaeza commented 2 years ago

Isn't there any public replacement in ir.model.data?

sebalix commented 1 year ago

Fixed in https://github.com/OCA/odoorpc/pull/79 , will be merged soon and published in the release v0.9.0.