跳至內容
選單
此問題已被標幟
1 回覆
2884 瀏覽次數

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. 

頭像
捨棄
最佳答案

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.

頭像
捨棄

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