This code works for me, and this is pretty much taken directly from the 6.1 code from what I recall:
from openerp.osv import osv,fields
class launch_map(osv.osv):
_inherit = "res.partner"
def open_map(self, cr, uid, ids, context=None):
if context is None:
context = {}
partner = self.browse(cr, uid, ids[0], context=context)
url = "http://maps.google.com/maps?oi=map&q="
if partner.street:
url += partner.street.replace(' ','+')
if partner.city:
url += '+'+partner.city.replace(' ','+')
if partner.state_id:
url += '+'+partner.state_id.name.replace(' ','+')
if partner.country_id:
url += '+'+partner.country_id.name.replace(' ','+')
if partner.zip:
url += '+'+partner.zip.replace(' ','+')
return {
'type': 'ir.actions.act_url',
'url': url,
'target': 'new'
}
In your view, just add a button on the partner that calls the open_map function. No more complicated than this:
<openerp>
<data>
<record model="ir.ui.view" id="view_partner_form_googlemaps">
<field name="name">res.partner.form.googlemaps</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet/div[@name='buttons']" position="inside">
<button name="open_map" string="Google Maps" type="object"/>
</xpath>
</field>
</record>
</data>
</openerp>
You can just add in your additional fields wherever they're necessary to fill out the address format in a single line, Google will take care of the rest.