Code:
SELECT f.id AS func_id
FROM product_product c
WHERE
(c.default_code = %d)
First of all: In your SQL there is no definition to f, so f.id would not return anything.
And ids is a list of integer database ids, you compare them to a character field default_code.
So I have to assume you left out something for this to be an example?
Second: instead of using SQL queries which may slow down your system, you should use the optimized browse functions of OpenERP.
Code:
def _get_nombre(self, cr, uid, ids, field_name, arg, context):
res = {}
for session in self.browse(cr, uid, ids, context=context):
if (session.default_code == False):
res[session.id] = session.product_tmpl_id.name
else:
res[session.id] = session.default_code
return res