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

How to get dictionary from product?

                        models_ids = self.env['product.template'].search([('id', '=', rule.product_id.id)])

                        my_dict = dict(models_ids)

example:

my_dict = {'id': 3, 'type': consu, 'categ_id': 1 ...e.t.c}

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

Hope this helps you 


prod_obj = self.env['product.template']
models_ids = self.env['product.template'].search([('id', '=', rule.product_id.id)])
for model in models_ids:
new_dict = model.read(list(set(prod_obj._fields)))
print(new_dict)
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can try like following method.

models_ids = self.env['product.template'].search_read(
[('id', '=', rule.product_id.id)])

Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 7 19
14780
0
thg 3 21
24
2
thg 7 19
4804
0
thg 1 21
3657
1
thg 2 25
1169