自定义 ir.actions.server

Custom ir.actions.server

我正在尝试为这样的模型定制 ir.actions.server

<?xml version="1.0"?>
<odoo>
<data>

<record model="ir.actions.server" id="action_recruitment_request_filter">
    <field name="name">Filter</field>
    <field name="type">ir.actions.server</field>
    <field name="model_id" ref="fhid_recruitment.model_recruitment_request"/>
    <field name="state">code</field>
    <field name="code">action = model.my_action()</field>
</record>

在这样的模型中

class RecruitmentRequest(models.Model):
    _name = 'recruitment.request'

    @api.multi
    def my_action(self):
        # import pdb; pdb.set_trace()
        return {
            'type': 'ir.actions.act_window',
            'res_model': 'recruitment.request',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'target': 'current',
            'context': {
                'search_default_my_requests': 1
            }
        }

但是我看不到这个函数对视图生效。即使我取消注释 set_trace() 我也看不到它进入方法。我在这里错过了什么?

这是带有操作的菜单

<record model="ir.actions.act_window" id="action_hr_recruitment_request">
    <field name="name">Requests</field>
    <field name="res_model">recruitment.request</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="form_view_id" ref="recruitment_request_form_view" />
    <field name="search_view_id" ref="hr_recruitment_request_view_search" />
    <field name="view_id" ref="hr_recruitment_request_tree" />
    <field name="context"></field>
    <!-- <field name="context" eval="{'search_default_by_responsible': 1}" /> -->
    <field name="help" type="html">
        <p class="o_view_nocontent_smiling_face">
            Create the first recruitment request
        </p><p>

        </p>
    </field>
</record>

<menuitem parent="hr_recruitment.menu_hr_recruitment_root" id="menu_hr_recruitment_request" 
    action="action_hr_recruitment_request" name="Requests" sequence="-1" />

您的服务器操作必须在 <menuitem> 作为操作中使用。