如何在 ODOO 中添加 Google 地图 link?
How do I add a Google Maps link in ODOO?
嘿,我有一个表格,所以我想要一个 google 在 odoo 中的地图视图,特别是在 HR 模块中,我将拥有所有员工的地址。所以当我点击特定视图时,它应该显示一些带有地图的视图
你必须继承 hr.employee
并使用 odoo 方法 google_map 在 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
这里是一个功能字段,使用合作伙伴地址和 return 地图计算地图数据 url。
使用这个字段,您可以使用 <img t-att-src="map"/>
轻松地在前端渲染地图
但如果您想在后端表单视图上呈现它,则必须创建一个使用生成的 url.(widget="image")
呈现图像的小部件
in google_map_img()
方法有额外的参数,如缩放、高度、宽度。根据您的需要更改。
这两种方法用于google地图图像和地图link。
def google_map_img(...)
pass
def google_map_link(...)
pass
在addons/website/models/website.py
中搜索此方法
如果您使用此方法,则根据您在 __openerp__.py
中的模块添加 website
模块
嘿,我有一个表格,所以我想要一个 google 在 odoo 中的地图视图,特别是在 HR 模块中,我将拥有所有员工的地址。所以当我点击特定视图时,它应该显示一些带有地图的视图
你必须继承 hr.employee
并使用 odoo 方法 google_map 在 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
这里是一个功能字段,使用合作伙伴地址和 return 地图计算地图数据 url。
使用这个字段,您可以使用 <img t-att-src="map"/>
但如果您想在后端表单视图上呈现它,则必须创建一个使用生成的 url.(widget="image")
in google_map_img()
方法有额外的参数,如缩放、高度、宽度。根据您的需要更改。
这两种方法用于google地图图像和地图link。
def google_map_img(...)
pass
def google_map_link(...)
pass
在addons/website/models/website.py
如果您使用此方法,则根据您在 __openerp__.py
website
模块