Reputation: 467
Hey I have one form so I wanted a google map view in odoo specially in HR Module I will be having address of all employees .So When I click on specific view it should show some view with map
Upvotes: 3
Views: 4047
Reputation: 1393
you have to inherit hr.employee
and use odoo method for google_map is in res.partner
.
like,
class hr_employee(osv.osv):
_inherit = "hr.employee"
_columns = {
'map': fields.function(google_map_img, string='Map', type='text'),
}
def google_map_img(self, cr, uid, ids, name, args, context=None):
employee = self.browse(cr, uid, ids[0], context=context)
if employee.address_id:
map_img_url = self.browse(cr, SUPERUSER_ID, ids[0], context=context).address_id.google_map_img()
return {ids[0]: map_img_url}
return None
here one functional field, that calculate the map data using partner address and return a map url.
using thism field you can easily render map on front-end using <img t-att-src="map"/>
but if you want to render it on back-end form view than you have to create a widget that render a image using generated url.(widget="image")
in google_map_img()
method has extra parameter like zoom, height, width. change as per your need.
this two method are use for google map image and map link.
def google_map_img(...)
pass
def google_map_link(...)
pass
search this method in addons/website/models/website.py
if you use this methods then add website
module in depends on your module in __openerp__.py
Upvotes: 1