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

RPCError when browsing a record which does not have a field `name` #57

Closed jcdrubay closed 3 years ago

jcdrubay commented 3 years ago

Version

OdooRPC==0.7.0 Odoo version: 14.0

Stacktrace

  File "{...}/lib/python3.7/site-packages/odoorpc/models.py", line 280, in browse
    return cls._browse(cls.env, ids)
  File "{...}/lib/python3.7/site-packages/odoorpc/models.py", line 246, in _browse
    records._init_values()
  File "{...}/lib/python3.7/site-packages/odoorpc/models.py", line 361, in _init_values
    self.ids, basic_fields, context=context, load='_classic_write')
  File "{...}/lib/python3.7/site-packages/odoorpc/models.py", line 74, in rpc_method
    cls._name, method, args, kwargs)
  File "{...}/lib/python3.7/site-packages/odoorpc/odoo.py", line 486, in execute_kw
    'args': args_to_send})
  File "{...}/lib/python3.7/site-packages/odoorpc/odoo.py", line 285, in json
    data['error'])
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "{...}/odoo/odoo/http.py", line 638, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "{...}/odoo/odoo/http.py", line 314, in _handle_exception
    raise exception.with_traceback(None) from new_cause
odoorpc.error.RPCError: Invalid field 'name' on model '{...}'

Workaround

Add a field name to the model being browsed.

wfamy commented 3 years ago

same pb with mrp.bom

odoorpc.version '0.7.0' Odoo 14.0 (Community Edition)

Bom=odoo.env['mrp.bom'] BOM.search([]) [1, 2, 3, 4,...] BOM.browse(1) Traceback (most recent call last): File "", line 1, in File "/home/bill/virtual/odoo/lib/python3.8/site-packages/odoorpc/models.py", line 280, in browse return cls._browse(cls.env, ids) File "/home/bill/virtual/odoo/lib/python3.8/site-packages/odoorpc/models.py", line 246, in _browse records._init_values() File "/home/bill/virtual/odoo/lib/python3.8/site-packages/odoorpc/models.py", line 360, in _init_values rows = self.class.read( File "/home/bill/virtual/odoo/lib/python3.8/site-packages/odoorpc/models.py", line 73, in rpc_method result = cls._odoo.execute_kw( File "/home/bill/virtual/odoo/lib/python3.8/site-packages/odoorpc/odoo.py", line 482, in execute_kw data = self.json( File "/home/bill/virtual/odoo/lib/python3.8/site-packages/odoorpc/odoo.py", line 283, in json raise error.RPCError( odoorpc.error.RPCError: Invalid field 'name' on model 'mrp.bom'

vanderperre commented 3 years ago

idem en v13 enterprise and mrp.bom

bizzappdev commented 3 years ago

52 is solving the problem.

MiquelRForgeFlow commented 3 years ago

This can be closed, right?

grey27 commented 3 years ago

Can you update the python package My current version of the PIP installation does not address this issue

MiquelRForgeFlow commented 3 years ago

You can use sudo pip install git+https://github.com/OCA/odoorpc.git@master#egg=odoorpc instead of sudo pip install odoorpc=0.7.0

jcdrubay commented 3 years ago

Sorry, but I am still facing that error even installing from the branch master :/

raise error.RPCError( odoorpc.error.RPCError: Invalid field 'name' on model 'base.module.update'

Then, I added a dummy field name and the issue was fixed.

Could it be because it's a TranscientModel ?

odoo_project = self._get_odoorpc(database, password)
module_update_env = odoo_project.env["base.module.update"]
log.info("Running 'Update Apps List'...")
updater_id = module_update_env.create({})
updater = module_update_env.browse(updater_id)
updater.update_module()

Interestingly, it's working when running on Odoo 12, but not on Odoo 13.

jcdrubay commented 3 years ago

After checking more in detail, I realized that I was still using an old version of OdooRPC. After forcing uninstall of odoorpc and re-installing, it worked well. 👍