<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <data>

        <record id="view_repair_order_form" model="ir.ui.view">
            <field name="name">repair.order.form.view</field>
            <field name="model">repair.order</field>
            <field name="inherit_id" ref="repair.view_repair_order_form" />
            <field name="arch" type="xml">
                <xpath
                    expr="//button[@name='action_created_invoice']"
                    position="before"
                >
                    <button
                        name="action_show_sales_order"
                        type="object"
                        class="oe_stat_button"
                        icon="fa-pencil-square-o"
                        attrs="{'invisible': [('sale_order_count', '=', 0.0)]}"
                        groups="sales_team.group_sale_salesman"
                    >
                        <field
                            name="sale_order_count"
                            widget="statinfo"
                            string="Sale Order(s)"
                        />
                    </button>
                </xpath>
                <xpath expr="//field[@name='invoice_state']" position="after">
                    <field name="create_sale_order" invisible="1" />
                </xpath>
                <xpath
                    expr="//button[@name='action_repair_start']"
                    position="attributes"
                >
                    <attribute
                        name="attrs"
                    >{'invisible': ['|', ('create_sale_order', '=', True), '&amp;', ('state','!=','confirmed'), '!', '&amp;', ('state','=','ready'), ('invoice_method','=','b4repair')]}</attribute>
                </xpath>
                <xpath expr="//button[@name='action_repair_start']" position="after">
                    <button
                        name="action_create_sale_order"
                        type="object"
                        string="Create Sales Order"
                        attrs="{'invisible': ['|', '|', ('create_sale_order', '=', False), ('sale_order_count', '&gt;', 0), ('state','!=','confirmed')]}"
                        class="oe_highlight"
                    />
                </xpath>
                <xpath expr="//field[@name='invoice_method']" position="attributes">
                    <attribute
                        name="attrs"
                    >{'invisible': [('create_sale_order', '=', True)]}</attribute>
                </xpath>
                <xpath expr="//field[@name='location_id']" position="attributes">
                    <attribute
                        name="attrs"
                    >{'invisible': [('create_sale_order', '=', True)]}</attribute>
                </xpath>
                <xpath
                    expr="//field[@name='operations']//tree//field[@name='type']"
                    position="attributes"
                >
                    <attribute
                        name="attrs"
                    >{'column_invisible': [('parent.create_sale_order', '=', True)]}</attribute>
                </xpath>
                <xpath
                    expr="//field[@name='operations']//tree//field[@name='lot_id']"
                    position="attributes"
                >
                    <attribute
                        name="attrs"
                    >{'column_invisible': [('parent.create_sale_order', '=', True)]}</attribute>
                </xpath>
                <xpath expr="//field[@name='partner_id']" position="attributes">
                    <attribute
                        name="attrs"
                    >{'required': ['|', ('create_sale_order', '=', True), ('invoice_method','!=','none')]}</attribute>
                </xpath>
            </field>
        </record>

    </data>
</odoo>
