英文:
In Odoo 13, XML-RPC, how can I update a field for multiple records?
问题
I'm attempting to update a field for multiple records.
尝试更新多个记录的字段。
The Odoo 13 Developer API document reads that it is possible, but does not give an example how.
Odoo 13开发者API文档中提到这是可能的,但没有提供示例。
"Multiple records can be updated simultaneously, but they will all get the same values for the fields being set."
"可以同时更新多个记录,但它们将获得相同的字段值。"
The below does not work:
以下代码不起作用:
models.execute_kw(db, uid, pw, 'table.name', 'write',
[[records_to_update], {'field': value}])
records_to_update is a list of the record ids.
records_to_update是记录ID的列表。
I receive this error:
我收到以下错误消息:
"-> message_values = dict((message_id, {}) for message_id in self.ids)"
I have spent quite some time searching for an answer and have come up blank so far.
我花了相当多的时间搜索答案,但迄今为止一无所获。
英文:
I'm attempting to update a field for multiple records.
The Odoo 13 Developer API document reads that it is possible, but does not give an example how.
https://www.odoo.com/documentation/13.0/developer/api/odoo.html#update-records
"Multiple records can be updated simultaneously, but they will all get the same values for the fields being set."
The below does not work:
models.execute_kw(db, uid, pw, 'table.name', 'write',
[[records_to_update], {'field': value}])
records_to_update is a list of the record ids.
I receive this error:
"-> message_values = dict((message_id, {}) for message_id in self.ids)"
I have spent quite some time searching for an answer and have come up blank so far.
答案1
得分: 1
应该看到以下错误消息:
不可哈希类型:'list'
records_to_update
是记录标识的列表,应该是 write
函数的第一个参数
示例:
models.execute_kw(db, uid, pw, 'table.name', 'write',
[records_to_update, {'field': value}])
英文:
You should see the following error message:
unhashable type: 'list'
records_to_update
is a list of the record ids and it should be the first argument to the write
function
Example:
models.execute_kw(db, uid, pw, 'table.name', 'write',
[records_to_update, {'field': value}])
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论