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),
}
product_product()
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