1
votes

I'm trying to add a custom filter for a state, basically I just needed to edit the string of an already existing filter. So I made this XML part but I can't quite figure out what I'm doing wrong here:

        <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>

New example:

     <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

1 Answers

1
votes

If you only want to change the string of existing filter than use attributes for example:

<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>