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

Hi,


I'm creating a custom data export module for products, and for this I want to export the external ID as well. However, this is not available as a default field. How can I access this?

I currently get my products something like:

self.env['product.template'].with_context(lang=active_language.code).search(
[('id', 'in', rec_list)], order='default_code')

External ID is the same one you get when you export a product and select "External ID".


Thanks!

形象
丢弃
编写者 最佳答案

I've got the solution myself already.

When you have retrieved a record, you can call 'get_metadata()'. This will return a list of all metadata you can see when going to "View Metadata" when in developer mode. Then you can say "get('xmlid')" to retrieve the xmlid.

So something like this would work:

products = self.env['product.template'].search([])
for product in products:
    product.get_metadata()[0].get('xmlid')



形象
丢弃
相关帖文 回复 查看 活动
1
12月 21
3802
1
9月 15
6799
1
7月 23
2299
2
6月 25
1562
0
3月 25
1396