Odoo Help


show supplier name in product tree view

on 5/31/13, 9:50 AM 2,184 views

I try to show supplier name in product tree view so i create this function :

class product_product(osv.osv):

    _inherit = 'product.product'

    def get_supplier_name(self, cr, uid, *args):
        cr.execute("select pt.name from res_partner pt  join product_supplierinfo fr on (fr.name=pt.id)  where fr.sequence = 1")
        res = cr.fetchone()
        return res

    _columns = {
      'supplier_name': fields.function(get_supplier_name, method=True,string="Supplier name",type="many2one", store = True),


But I have this error :

    Traceback (most recent call last): File "netsvc.pyo", line 489, in dispatch File "service\web_services.pyo", line 599, in dispatch File "osv\osv.pyo", line 122, in wrapper File "osv\osv.pyo", line 176, in execute File "osv\osv.pyo", line 167, in execute_cr File "osv\orm.pyo", line 2940, in read File "osv\orm.pyo", line 3060, in _read_flat File "osv\fields.pyo", line 799, 
in get AttributeError: 'tuple' object has no attribute 'values'

What can I do?

I rectify the type of the field "supplier_name" to char and I've thie error : TypeError: int argument required

on 5/31/13, 11:26 AM

Andreas Brueckl

--Andreas Brueckl--

| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 5/31/13, 11:42 AM

Try this method (assuming, that the type of the function field is many2one):

def get_supplier_name(self, cursor, user, ids, name, arg, context=None):
    res = {}
    for product in self.browse(cursor, user, ids, context=context):
        if product.seller_ids:
          res[product.id] = product.seller_ids[0].id
          res[product.id] = False
    return res

I tried your method but : get AttributeError: 'NoneType' object has no attribute 'name_get'

on 5/31/13, 11:51 AM

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

0 follower(s)


Asked: 5/31/13, 9:50 AM
Seen: 2184 times
Last updated: 3/16/15, 8:10 AM