Odoo 10:如何将参数从按钮传递到树视图?
Odoo 10 : How to pass parameter to a tree view from button?
我在联系人表单中添加了一个按钮,如下所示:
<xpath expr='//div[@class="oe_button_box"]//button[@name="toggle_active"]' position='after'>
<button type="action" name="%(survey.action_survey_user_input)d" string="Surveys" class="oe_stat_button"/>
</xpath>
这会打开下面的调查树视图,但没有对电子邮件 ID 进行筛选。如何使用此按钮将电子邮件 ID 传递到下面的调查树视图?
信息:我尝试在按钮标签中添加上下文但没有成功。
context="{'email': email}"
您可以使用对象类型的按钮来更好地实现 python 中的所有内容,方法是返回具有所需操作域的操作字典以过滤树视图上的记录或使用 rec_id 打开特定记录表
这个 python 函数对我有用,它由按钮调用(类型:对象)
@api.multi
def callSurvey(self):
self.ensure_one()
action_id = self.env.ref('survey.action_survey_user_input').read()[0]
if action_id:
return {
'name': action_id['name'],
'type': action_id['type'],
'res_model': action_id['res_model'],
'view_type': action_id['view_type'],
'view_mode': action_id['view_mode'],
'search_view_id': action_id['search_view_id'],
'domain': [["email", "=", self.email]],
'help': action_id['help'],
}
我在联系人表单中添加了一个按钮,如下所示:
<xpath expr='//div[@class="oe_button_box"]//button[@name="toggle_active"]' position='after'>
<button type="action" name="%(survey.action_survey_user_input)d" string="Surveys" class="oe_stat_button"/>
</xpath>
这会打开下面的调查树视图,但没有对电子邮件 ID 进行筛选。如何使用此按钮将电子邮件 ID 传递到下面的调查树视图?
信息:我尝试在按钮标签中添加上下文但没有成功。
context="{'email': email}"
您可以使用对象类型的按钮来更好地实现 python 中的所有内容,方法是返回具有所需操作域的操作字典以过滤树视图上的记录或使用 rec_id 打开特定记录表
这个 python 函数对我有用,它由按钮调用(类型:对象)
@api.multi
def callSurvey(self):
self.ensure_one()
action_id = self.env.ref('survey.action_survey_user_input').read()[0]
if action_id:
return {
'name': action_id['name'],
'type': action_id['type'],
'res_model': action_id['res_model'],
'view_type': action_id['view_type'],
'view_mode': action_id['view_mode'],
'search_view_id': action_id['search_view_id'],
'domain': [["email", "=", self.email]],
'help': action_id['help'],
}