コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
12583 ビュー

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}

アバター
破棄
最善の回答

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)
アバター
破棄
最善の回答

Hi,

You can try like following method.

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

Regards

アバター
破棄
関連投稿 返信 ビュー 活動
3
7月 19
14777
0
3月 21
24
2
7月 19
4794
0
1月 21
3656
1
2月 25
1164