Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
7981 Visualizzazioni

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!

Avatar
Abbandona
Autore Risposta migliore

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



Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
dic 21
4047
1
set 15
6960
1
lug 23
2435
1
ago 25
359
2
giu 25
1808