Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2875 Lượt xem

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. 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ

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