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

I don't have much expirience with python, i need to change this code to return a list of suppliers.

def _get_main_product_supplier(self, cr, uid, product, context=None):       

        sellers = [(seller_info.sequence, seller_info)
                       for seller_info in product.seller_ids or []
                       if seller_info and isinstance(seller_info.sequence, (int, long))]
        return sellers and sellers[0][1] or False

Thanks in advance. 

Avatar
Abbandona
Risposta migliore

def _get_main_product_supplier(self, cr, uid, product, context=None):       

        sellers = [(seller_info.sequence, seller_info)
                       for seller_info in product.seller_ids or []
                       if seller_info and isinstance(seller_info.sequence, (int, long))]
        return sellers and [x[1] for x in sellers[0][1]] or False

This will return list of seller_info means instead of singel supplier it will return all.

Avatar
Abbandona

return sellers and [x[1] for x in sellers] or False