<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="view_order_form" model="ir.ui.view">
        <field name="name">sale.order.form</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form" />
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/div/h1" position="after">
                <p>
                    <label
                        for="cancel_reason_id"
                        string="Cancellation reason:"
                        invisible="state != 'cancel'"
                    />
                    <field
                        name="cancel_reason_id"
                        class="oe_inline"
                        options='{"no_open": True}'
                        invisible="state != 'cancel'"
                    />
                </p>
            </xpath>
        </field>
    </record>
    <record model="ir.ui.view" id="view_sale_order_cancel_reason_form">
        <field name="name">Sale Order Cancel Reason</field>
        <field name="model">sale.order.cancel.reason</field>
        <field name="arch" type="xml">
            <form string="Sale Order Cancel Reasons">
                <field name="name" />
            </form>
        </field>
    </record>
    <record model="ir.ui.view" id="view_sale_order_cancel_reason_tree">
        <field name="name">Sale Order Cancel Reason</field>
        <field name="model">sale.order.cancel.reason</field>
        <field name="arch" type="xml">
            <list>
                <field name="name" />
            </list>
        </field>
    </record>
    <record model="ir.actions.act_window" id="action_sale_order_cancel_reason">
        <field name="name">Sale Order Cancel Reason</field>
        <field name="res_model">sale.order.cancel.reason</field>
        <field name="view_mode">list,form</field>
    </record>
    <menuitem
        id="menu_sale_order_cancel_reason"
        parent="sale.menu_sale_config"
        name="Sale Order Cancel Reasons"
        action="action_sale_order_cancel_reason"
        sequence="150"
        groups="sales_team.group_sale_manager"
    />
</odoo>
