<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2019 Akretion
    License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
    <record id="sale_order_view_form" model="ir.ui.view">
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form" />
        <field name="arch" type="xml">
            <xpath expr="//header" position="after">
                <header name="substate">
                    <field
                        name="substate_id"
                        widget="statusbar"
                        options="{'clickable': '1',}"
                        domain="[('model', '=', 'sale.order'),('target_state_value_id.target_state_value', '=', state)]"
                    />
                </header>
            </xpath>
        </field>
    </record>

    <record id="view_order_tree" model="ir.ui.view">
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_tree" />
        <field name="arch" type="xml">
            <field name="state" position="after">
                <field name="substate_id" />
            </field>
        </field>
    </record>

    <record id="view_quotation_tree" model="ir.ui.view">
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_quotation_tree" />
        <field name="arch" type="xml">
            <field name="state" position="after">
                <field name="substate_id" />
            </field>
        </field>
    </record>

    <record id="view_sales_order_filter" model="ir.ui.view">
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_sales_order_filter" />
        <field name="arch" type="xml">
            <field name="user_id" position="after">
                <field name="substate_id" />
            </field>
            <filter name="order_month" position="after">
                <filter
                    name="substate_id"
                    string="Substate"
                    domain="[]"
                    context="{'group_by':'substate_id'}"
                />
            </filter>
        </field>
    </record>
</odoo>
