This question has been flagged
2 Replies
7071 Views

Hi all,

I want to localize location, how to achieve like link below in openerp7/odoo

let say, when you select City then in the next field should appear only all the province for that city.

for instance:

 

city1 ------ province1

               province2

               province3

http://www.olx.ph/index.php/select+location/parent/adUpdate/field/location/selected/

 

Thanks

Avatar
Discard
Author Best Answer

XML

<field name="abs_provinces_id" style="width: 50%%"/>
<field name="abs_cities_id" style="width: 48.2%%" domain="[('abs_provinces_id', '=', abs_provinces_id)]"/>
<field name="abs_zip" placeholder="ZIP" style="width: 8%%" invisible="1"/> 

PYTHON

class abs_provinces(osv.Model):
    _name = "abs.provinces"
    _columns = {
        'name': fields.char('Province', size=32),
    }

class abs_cities(osv.Model):
    _name = "abs.cities"
    _columns = {
        'name': fields.char('City', size=32),
        'abs_provinces_id': fields.many2one('abs.provinces', 'Province'),
    }

Avatar
Discard
Best Answer

look for openerp / odoo module named city, it does exactlky that.. 
adds a new model for unique city entriey, conects them to zip codes, states etc... 

also you might want to check python package py-country  , wich contains all countries and states in the world.. 

If you decide to use module city, be aware that it might cause incompatability issues with other custom modules.. 

Avatar
Discard