在OpenERP中更改现有的过滤字符串

时间:2015-02-27 11:04:12

标签: openerp openerp-7 odoo

我尝试为状态添加自定义过滤器,基本上我只需编辑现有过滤器的字符串。所以我制作了这个XML部分,但我无法弄清楚我在这里做错了什么:

        <record id="sale_order_list_select" model="ir.ui.view">
        <field name="name">sale.order.list.select</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="base.view_sales_order_filter"/>
        <field name="arch" type="xml">
            <search position="inside">
                <filter icon="terp-dolar_ok!" string="WON" domain="[('state','=','manual')]"
                        help="Sales Order ready to be invoiced"/>
            </search>
        </field>
    </record>

新例子:

     <record id="sale_order_list_select" model="ir.ui.view">
        <field name="name">sale.order.list.select</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_sales_order_filter"/>
        <field name="arch" type="xml">
            <filter string="To Invoice" position="attributes">
                <attribute name="string">WON</attribute>
            </filter>
            <filter string="Done" position="attributes">
                <attribute name="string">LOST</attribute>
                <attribute name="domain">[('state','=','cancel' )]</attribute>
            </filter>
            <filter string="Sales" position="attributes">
                <attribute name="string">HOLD</attribute>
            </filter>
        </field>
    </record>

1 个答案:

答案 0 :(得分:1)

如果您只想更改现有过滤器的字符串而不是使用attributes,例如:

<record id="sale_order_list_select" model="ir.ui.view">
    <field name="name">sale.order.list.select</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_sales_order_filter"/>
    <field name="arch" type="xml">
        <filter string="To Invoice" position="attributes">
            <attribute name = "string">WON</attribute>
        </filter>
        <!-- After "Sales" filter it will add new "Cancel" filter -->
        <filter string="Sales" position="after">
            <filter icon="terp-dolar_ok!" string="Cancel" domain="[('state','=','cancel')]" help="Sales Order which are canceled"/>
        </filter>
    </field>
</record>