Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
6259 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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)">

Autore

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.

Post correlati Risposte Visualizzazioni Attività
2
feb 24
16474
1
dic 22
5641
2
dic 22
15391
2
giu 22
7458
2
giu 22
5545