跳至内容
菜单
此问题已终结
2 回复
12539 查看

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
14729
0
3月 21
24
2
7月 19
4736
0
1月 21
3616
1
2月 25
1097