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

Hello all,

In the new API, the search() method returns a recordset. For example, this code :

ids = self.search([('default_code', operator, name)])

COuld return something like this :

ids = product.product(1366, 1365, 1325, 1303, 1297, 1296, 1295, 1291)


How could I obtains a list of IDs like this instead????

ids = [1366, 1365, 1325, 1303, 1297, 1296, 1295, 1291]


Thanks


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

I have found how to get an ids list.

Just use :

ids.ids

to get :

[1366, 1365, 1325, 1303, 1297, 1296, 1295, 1291]

Ảnh đại diện
Huỷ bỏ
Tác giả

Probably that products.ids would be a better name for my variable instead of ids.ids...

Câu trả lời hay nhất

Hi Pascal,

You can also use like,

ids = self.search([('default_code', operator, name)]).ids


Regards,

Anil.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
write() vs update() Đã xử lý
4
thg 9 20
41884
New Odoo api Đã xử lý
1
thg 3 15
3632
1
thg 2 16
4009
0
thg 10 22
3236
0
thg 3 15
5304