嘿,我有一个表格,所以我想要一个特别在HR模块中的odoo谷歌地图视图我将获得所有员工的地址。所以,当我点击特定视图时,它应该显示一些带地图的视图
答案 0 :(得分:1)
你必须继承hr.employee
并使用forogle_map的odoo方法在res.partner
。
等
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
这里有一个功能字段,它使用合作伙伴地址计算地图数据并返回地图网址。
使用thism字段,您可以使用<img t-att-src="map"/>
但是如果要在后端表单视图上呈现它,则必须创建使用生成的URL呈现图像的窗口小部件。(widget="image")
google_map_img()
方法中的有额外的参数,如缩放,高度,宽度。根据您的需要改变。
这两种方法用于谷歌地图图像和地图链接。
def google_map_img(...)
pass
def google_map_link(...)
pass
在addons/website/models/website.py
如果您使用此方法,则添加website
模块取决于__openerp__.py