Odoo Help


Need to get my method to output the partner name not just the id and have it select it only from the suppliers in the product I

Emmanuel Roldan
on 8/14/14, 5:02 PM 717 views

I have two problems with my code:

  1. I need get the partner name not just the id
  2. and its searching all the partners not just the ones on the product I am selecting in product_id

Here is my code:

    def get_product_provider(self, cr, uid, ids, field_name, args=None, context=None):
        res = {}
        for record in self.browse(cr, uid, ids, context=context):
            cr.execute('''select id from product_supplierinfo where product_tmpl_id in (select id from product_template) order by RANDOM() limit 1''')
            val = cr.fetchone()
            if val:
                res[record.id] = val[0]
                res[record.id] = False
            return res

_columns = {
        'ServicesID': fields.char('Services ID', size=15),
        'product_id': fields.many2one('product.product', 'name', 'Service Name'),
        'product_is_random': fields.related('product_id', 'is_random', type='boolean', string='Product is Random', readonly=True),

        'AppNum': fields.many2one('itaconloans.e3loan', 'Application Number', select=True),

        'provider': fields.many2one('res.partner', 'Provider Name', select=True),
        'random_seller_info_id': fields.function(get_product_provider, type='many2one', relation="product.supplierinfo", string="Random Supplier", store=True),
        #'random_provider': fields.related('random_seller_info_id', 'name', type='many2one', string='Provider Name', readonly=True),

        'DateReq': fields.date('Date Requested'),
        'DateComp': fields.date('Date Completed'),
        'DateToComp': fields.date('Date To Complete'),
        'comments': fields.text('Comments', translate=True),


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/14/14, 5:02 PM
Seen: 717 times
Last updated: 3/16/15, 8:10 AM