OpenERP - 从按钮传递域名 - >行动 - >搜索视图

时间:2013-06-27 12:23:08

标签: openerp

我有一个按钮如下:

<button string="View Cancelled Applications" name="%(action_recruit_application)d" type="action" domain="[('state','=','cancel')]"/>

行动如下:

<record model="ir.actions.act_window" id="action_recruit_application">
    <field name="name">Applications</field>
    <field name="res_model">recruit.application</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="search_view_id" ref="view_recruit_application_search"/>
   </record>

最后,搜索视图如下:

    <record model="ir.ui.view" id="view_recruit_application_search">
    <field name="name">recruit.application.search</field>
    <field name="model">recruit.application</field>
    <field name="arch" type="xml">
        <search string="Applications">
            <field name="application_id"/>
            <field name="name"/>     
            <field name="application_date"/>
            <field name="state"/>
        </search>
    </field>
</record>

我似乎无法将'state'='cancel'传递给搜索视图。

有人可以帮帮我吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

尝试在按钮中添加上下文。例如

<button string="View Cancelled Applications" name="%(action_recruit_application)d" type="action" domain="[('state','=','cancel')]" context="{'search_default_state':'cancel'}"/>