如何将fielter添加到one2many树视图?

时间:2015-12-04 10:46:40

标签: python openerp

这是feedback.form .py文件         来自openerp.osv导入字段,osv         来自openerp import api         导入日志记录

    class feedback_form(osv.Model):
        _name = 'feedback.form'
        _rec_name = 'company_id111'
        _columns = {
            'company_id111': fields.many2one('res.company', 'Substation', required=True),
            'completed': fields.boolean('Completed',default=False,readonly=False,required=False),

            'frequency' : fields.char('Frequency'),
            'shutdown' : fields.char('Shut Down'),
            'insp_rslt' : fields.one2many('feedback.tree','insp_rsltts','Inspection Result',),

        }

        def get_detail_emp(self, cr, uid, ids, folionum, context=None):
            val = {}
                res = []
                if folionum:
                        for mom in self.pool.get('calendar.event').browse(cr,uid,folionum,context=context):
                            val = {
                                        'inspec_type' : mom.inspection_name,

                                     }
                            res.append(val)

                return {'value': val} 


    feedback_form()

    class feedback_tree(osv.Model):
        _name = 'feedback.tree'
        _rec_name = 'insp_rsltts'
        STATUS = [
            ('0', 'Completed'),
            ('1', 'Not-Completed'),
        ]

        _columns = {
            'folionum' : fields.many2one('calendar.event','Maintenance ID',),
            'folio_number' : fields.many2one('asset.asset','Folio number',),
            'inspec_type' : fields.many2one('asset1.inspection','Inspection Type',),
            'insp_msr1' : fields.many2one('results.measure','Attributes',),
            'valuess' : fields.char('Values'),
            'status' : fields.selection(STATUS,'Status'),
            'insp_rsltts': fields.many2one('feedback.form','Result Id'),


        }
        def onchange_insp(self, cr, uid, ids, folionum,context=None):
            dids = []
            res = {}
            for record in self.pool.get('calendar.event').browse(cr, uid, folionum, context=context):
                dids = [x.id for x in record.inspection_name]
            dids1 = []
            for record in self.pool.get('calendar.event').browse(cr, uid, folionum, context=context):
                dids1 = [x.id for x in record.folio_num1]
            res.update({'inspec_type':[('id','in',dids)]})
            res.update({'folio_number':[('id','in',dids1)]})
            return {'domain':res}

        def onchange_measure(self, cr, uid, ids, inspec_type, context=None):
            dids = []
            for record in self.pool.get('asset1.inspection').browse(cr, uid, inspec_type, context=context):
                dids = [x.id for x in record.msr_insp]
            return {'domain':{'insp_msr1':[('id','in',dids)]}}


    feedback_tree()


<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

    <!-- Form & Tree View for Visitor Register -->
    <record model="ir.ui.view" id="feed_back_event">
            <field name="name">feedback.form.form</field>
            <field name="model">feedback.form</field>

            <field name="arch" type="xml">
               <form string="feedback">
                    <group>
                       <!-- <field name="number"/>-->
            <field name="company_id111"/>







            </group>
            <hr/><group>
            <!--<group><group><field name="insp_msr1" options="{'no_create': True, 'no_open': True}"/></group><group>--><field name="insp_rslt">            <tree string="Insp Result" editable="bottom">

                <field name="folionum" options="{'no_create': True, 'no_open': True}" on_change="onchange_insp(folionum)"/>
            <!--<field name="place" on_change="onchange_place(place)"/>-->
            <field name="folio_number" options="{'no_create': True, 'no_open': True}"/>


            <field name="inspec_type" on_change="onchange_measure(inspec_type)"/>
            <field name="insp_msr1"/>
            <field name="valuess"/>
            <field name="status"/>  
            </tree>
            </field>


            </group>





        <group>
            <field name="completed"/></group>
               </form>
    </field>
        </record>




    <record id="feed_back_action" model="ir.actions.act_window">
            <field name="name">Maintenance Feedback Form</field>
            <field name="res_model">feedback.form</field>
            <field name="view_type">form</field>    

            <field name="help" type="html">
                    <p class="oe_view_nocontent_create">Click to create a new Maintenance Feedback</p>
            </field>    
            </record>
    **<record id="feed_back_filter" model="ir.ui.view">
            <field name="name">Feedback</field>
            <field name="model">feedback.form</field>
            <field name="arch" type="xml">
                <search string="Feedback">

                    <!--<field name="completed" />-->

                    <group expand="0" string="Group By">

                        <filter string="Pending" domain="[]" context="{'group_by':'insp_rslt'}"/>

                    </group>
                </search>
             </field>
         </record>**
    <menuitem id="feedback_configs" name="Maintenance Feedback"/>
        <menuitem id="substation_feedback_menu" name="Maintenance Feedback " parent="base.menu_mro_root"/>
        <menuitem id="feed_back_creation" name="Maintenance Feedback Form" parent="substation_feedback_menu" action="feed_back_action"/>


    </data>
</openerp>

如何在xml文件中添加feedback.tree类的 status 字段。我有一些可能性,但我得到

1 个答案:

答案 0 :(得分:0)

开箱即用这是限制,因此您需要为此创建一些解决方法。您可以在模型feedback.form上执行的操作,您可以创建一个计算文本字段并存储o2m字段state insp_rslt(确保使计算字段为{{} 1}}),然后在视图中添加字段,以便您在计算字段上进行过滤和分组。

是的,你可以说这里的02M字段记录可以有多个状态,因为你可以将它们存储为文本字段,它可以让你根据包含进行过滤。或者,您可以聚合并存储一个制作计算选择字段的状态。

贝斯茨