← Back to team overview

credativ team mailing list archive

[Question #185725]: Example code for many2one - problem

 

New question #185725 on OpenERP Server:
https://answers.launchpad.net/openobject-server/+question/185725

Hi all.

I'm trying to build a module for my needs and I'm experimenting some sample codes.

In this example, I need to build a very simple City-State relationship, but I'm getting a error from the server:

Follow the code:


class city(osv.osv):
    _name = 'city'
    _columns = {
        'cityName': fields.char('City', size=32),
        'State': fields.many2one('state','name'),
    }
city()

class state(osv.osv):
    _name = 'state'
    _columns = {
        'name': fields.char('State name',size=32),
    }
state()

The error in the server is:

ERROR:db.cursor:Programming error: operator does not exist: character varying = integer
LINE 1: ...te".id FROM "state" WHERE (state.name in (1,2,3)...
                                                                                          ^

HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
, in query SELECT "state".id FROM "state" WHERE (state.name in (%s,%s,%s)) ORDER BY id 

I believe my code is wrong, but I could not find easy examples on the net to fix it.

Can you help me?

Thanks in advance

-- 
You received this question notification because you are a member of
OpenERP Framework Experts, which is an answer contact for OpenERP
Server.