OpenERP 7:设置分组依据的默认值

时间:2014-01-21 06:11:44

标签: openerp

我按手动订单参考分组POLine,它过滤数据,如下图所示。

<record id="view_purchase_line_search" model="ir.ui.view">
        <field name="name">purchase.order.line.search</field>
        <field name="model">purchase.order.line</field>
        <field name="arch" type="xml">
            <search string="Search Purchase Order">
                <field name="order_id"/>
                <field name="partner_id" string="Supplier" filter_domain="[('partner_id', 'child_of', self)]"/>                  
                <group expand="1" string="Group By...">
                <filter icon="terp-gtk-jump-to-rtl" string="Order Reference" domain="[]" context="{'group_by' :'order_id'}"/>
                <filter string="Supplier" icon="terp-partner" domain="[]" context="{'group_by' : 'partner_id'}" />                    
                </group>
            </search>
        </field>
</record>

<record id="view_purchase_line_list" model="ir.ui.view">
        <field name="name">purchase.order.line.tree</field>
        <field name="model">purchase.order.line</field>
        <field name="arch" type="xml">
            <tree string="Purchase Order Lines" create="false">                    
                <field name="order_id"/>
                <field name="partner_id" string="Supplier" />
                <field name="product_id"/>
                <field name="price_unit"/>
                <field name="product_qty"/>
                 <field name="product_uom" groups="product.group_uom"/>
                <field name="price_subtotal"/>
                <field name="date_planned"  widget="date" width="135"/>
                <field name="state" invisible="1"/>
                <field name="invoiced" invisible="1"/>
            </tree>
        </field>
</record>                   


<record id="action_purchase_line_list" model="ir.actions.act_window">
    <field name="name">PO Tree Structure</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">purchase.order.line</field>
    <field name="view_id" ref="view_purchase_line_list"/>
    <field name="context">{'search_default_order_id':1 }</field>
    <field name="search_view_id" ref="view_purchase_line_search"/>  
</record> 

<menuitem action="action_purchase_line_list" id="menu_purchase_list"
        parent="menu_procurement_management"
        sequence="0"/>

但我默认需要这个过滤器(即)在第一次打开这个窗口时它应该对数据进行分组

enter image description here

尝试下面的代码:

<field name="context">{'search_default_order_id':1 }</field>

enter image description here

我需要在搜索字段中使用“订单参考”代替订单参考POOOO1 。  任何建议都会有所帮助。

2 个答案:

答案 0 :(得分:2)

试试这个,在 purchase_view.xml 文件中搜索此ID view_purchase_order_filter ,然后在分组依据中添加以下过滤器...

<filter icon="terp-gtk-jump-to-rtl" name="order_id" string="Order Reference" domain="[]" context="{'group_by' :'name'}"/>

找到此ID purchase_form_action 并粘贴到上下文

<field name="context">{'search_default_order_id': 1}</field>

希望这会对你有所帮助。

答案 1 :(得分:2)

update your code with this.

<filter name="groupby_order" icon="terp-gtk-jump-to-rtl" string="Order Reference" 
domain="[]" context="{'group_by' :'order_id'}"/>  

and pass <field name="context">{'search_default_groupby_order': 1}</field> in 
act_window. Hope this will be useful to you.