Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
5931 Vistas

I want to change a custom boolean field from invoice from FALSE to TRUE. I've been reading the documentation for using Odoo API and tried to adapt the code in given in the example as shown below. (I'm using python3)


invoice_read3 = models.execute_kw(
db, uid, password, 'account.invoice', 'search_read',
[[('id', '=', 1)]])

models.execute_kw(
db, uid, password, 'account.invoice', 'write', [[invoice_read3],
{'x_processed': True}])


But it returns the following error.


xmlrpc.client.Fault: <Fault 1: 'Traceback (most recent call last):(...)prefetch[cls._name].update(ids)\nTypeError: unhashable type: \'list\'\n'>

Also, My boolean field is not 'readonly', how would it affect the code if i change it to 'readonly' ? Thanks in advance.

Avatar
Descartar
Mejor respuesta

Hello Jean,

If you already have ID of invoice then you should directly use it in write operation as following :

models.execute_kw(db, uid, password, 'account.invoice', 'write', [[1], {'x_processed': True}])

Thanks,

Avatar
Descartar
Autor

Hello, Emipro

I have already done that and now i have authorization problems. Even tho I am the administrator. I have already done my Odoo conexion as in the Documentation. Is there anything new to add to my python3 code in order to get elevated authorization?

xmlrpc.client.Fault: <Fault 4: "('Sorry, you are not allowed to modify this document. Please contact your system administrator if you think this is an error.\\n\\n(Document model: account.invoice)', None)">

Autor

Nevermind. I figured it out. In order to give authorization for write, delete, create or read you need to give that kind of permission to the group you want to use.

Just go to Odoo 11 then go to Settings and under "Technical" Tab go to Security, then select "Acces Control List"

In there just search for the group you want to modify it's authorization and just check the checkbox for the kind of permission you want. Hope it helps other people.

Publicaciones relacionadas Respuestas Vistas Actividad
2
feb 24
15342
1
dic 22
4897
2
dic 22
14284
2
jun 22
6138
2
jun 22
4549