تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
6257 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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,

الصورة الرمزية
إهمال
الكاتب

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

الكاتب

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.

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
فبراير 24
16473
1
ديسمبر 22
5641
2
ديسمبر 22
15390
2
يونيو 22
7458
2
يونيو 22
5545