Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7833 มุมมอง

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')



อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
External ID is not set on products แก้ไขแล้ว
1
ธ.ค. 21
3896
1
ก.ย. 15
6888
1
ก.ค. 23
2362
1
ส.ค. 25
182
2
มิ.ย. 25
1693