Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
11843 Tampilan

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}

Avatar
Buang
Jawaban Terbai

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)
Avatar
Buang
Jawaban Terbai

Hi,

You can try like following method.

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

Regards

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
3
Jul 19
14077
0
Mar 21
24
2
Jul 19
4285
0
Jan 21
3244
1
Feb 25
387