<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright 2019-2020 Akretion France (http://www.akretion.com/)
  @author: Alexis de Lattre <alexis.delattre@akretion.com>
  License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

<odoo>

<record id="account_invoice_form" model="ir.ui.view">
    <field name="name">sale_usability.customer.invoice.form</field>
    <field name="model">account.move</field>
    <field name="inherit_id" ref="sale.account_invoice_form" />
    <field name="groups_id" eval="[(4, ref('sales_team.group_sale_manager'))]" />
    <field name="arch" type="xml">
        <div name="button_box" position="inside">
            <button
                name="show_sale_orders"
                type="object"
                class="oe_stat_button"
                icon="fa-pencil-square-o"
                attrs="{'invisible': [('sale_count', '=', 0)]}">
                <field name="sale_count" widget="statinfo" string="Sale Orders" />
            </button>
        </div>
    </field>
</record>

<record id="view_move_form" model="ir.ui.view">
    <field name="name">sale_usability.account.move.form</field>
    <field name="model">account.move</field>
    <field name="inherit_id" ref="account.view_move_form"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='invoice_line_ids']/form//field[@name='analytic_account_id']" position="after">
            <field name="sale_line_ids" widget="many2many_tags" attrs="{'invisible': [('sale_line_ids', '=', [])]}"/>
        </xpath>
    </field>
</record>

</odoo>
