Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Modify code to provide a list

By
Emmanuel Roldan
on 6/17/14, 1:14 PM 631 views

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. 

0
Ruchir Shukla
On 6/18/14, 2:02 AM

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

Ruchir Shukla
on 6/18/14, 2:03 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/17/14, 1:14 PM
Seen: 631 times
Last updated: 3/16/15, 8:10 AM