Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5593 Lượt xem

Please help on the below error. I couldn't solve it.

Odoo version: 16 community edition


result = method(recs, *args, **kwargs)

TypeError: write() takes 2 positional arguments but 3 were given

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thank you for the answer, I couldn't trace the file which is causing the error. Could you help me on this?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Here's an example of how to use the write() method correctly:

# Assuming you have a recordset 'recs' and you want to update the 'field1' and 'field2' values
# Example 1: Updating a single record
recs.write({'field1': new_value1, 'field2': new_value2})

# Example 2: Updating multiple records
for record in recs:
    record.write({'field1': new_value1, 'field2': new_value2})

If you are getting the error "write() takes 2 positional arguments but 3 were given," it might be due to the incorrect usage of the write() method. Make sure that you are passing only one argument, which is the dictionary containing the field-value pairs to be updated.


Hope it helps

Ảnh đại diện
Huỷ bỏ