简体   繁体   English

如何在odoo v8中编写搜索视图?

[英]How to write search views in odoo v8?

I have been trying to write search view for a class which has inherited from other class and I have tried writing the search view for it and also added a filter to it. 我一直在尝试为从其他类继承的类编写搜索视图,并且尝试为其编写搜索视图并向其中添加过滤器。 But I am slightly confused on how to get things together. 但是我对如何使事情融合在一起感到有些困惑。

The following is the sequence of code: 以下是代码序列:

This is the class I have used for the search view 这是我用于搜索视图的类

class mom_ac(osv.osv):
    _name='mom.ac'
    _inherit='mom.action'
    _columns = {
        'new_field':fields.char('Action'),
    }

and the corresponding search view for the above class along with filter 以及上述类别的相应搜索视图以及过滤器

<record id="minutes_meeting_search_view" model="ir.ui.view">
    <field name="name">mom.ac</field>
    <field name="model">mom.ac</field>
    <field eval="10" name="priority"/>
    <field name="arch" type="xml">
        <search string="MoM">
            <filter icon="terp-mail-message-new" string="Action Items" name="my_requests_filter" domain="[('Status','!=','Done')]" />
            <field name="act_ion"/>
        </search>
    </field>
</record>

The following is the class from which it has been inherited 以下是继承自其的类

class mom_action(osv.Model):
    _name = 'mom.action'
    _columns = { 
        'act_ion' : fields.char('Action'),
        'meeting_id' : fields.many2one('mom.meeting','Meeting Id'),
        'asgnd_to': fields.many2one('res.users','Assigned To'),
        'due_date': fields.date('Due Date'),
        'Status'  : fields.selection([
                                    ('Yet to Start','Yet To Start'),
                                    ('In Progress', 'In Progress'),
                                    ('Done', 'Done'),
                    ], 'Status', readonly= False, select=True, default='Yet to Start'),
    }

mom_action()

When I click on my filter, it does not display list view with results and also when I try with Advanced Search provided by Search view, results are not shown. 当我单击过滤器时,它不会显示带有结果的列表视图,并且当我尝试使用“搜索”视图提供的“高级搜索”时,也不会显示结果。

Please help me on this. 请帮我。

If you want only inherit you must use only _inherit in your inherited model. 如果只希望继承,则必须在继承的模型中仅使用_inherit Remove the _name : 删除_name

class mom_ac(osv.osv):
    _inherit='mom.action'
    _columns = {
        'new_field':fields.char('Action'),
    }

And you should write your original model in the search view: 您应该在搜索视图中编写原始模型:

<record id="minutes_meeting_search_view" model="ir.ui.view">
    <field name="name">mom action search view</field>
    <field name="model">mom.action</field>
    <field eval="10" name="priority"/>
    <field name="arch" type="xml">
        <search string="MoM">
            <filter icon="terp-mail-message-new" string="Action Items" name="my_requests_filter" domain="[('Status','!=','Done')]" />
            <field name="act_ion"/>
            <field name="new_field"/>
        </search>
    </field>
</record>

Is that what you are looking for? 那是您要找的东西吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM