<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record model="ir.ui.view" id="account_analytic_account_view_inherit_sale_subscription">
        <field name="name">account.analytic.account.view.buttons.subscription_count</field>
        <field name="model">account.analytic.account</field>
        <field name="inherit_id" ref="analytic.view_account_analytic_account_form" />
        <field name="priority" eval="22"/>
        <field name="groups_id" eval="[(4, ref('odex25_sale_subscription.group_sale_subscription_view'))]"/>
        <field name="arch" type="xml">
            <div name="button_box" position="inside">
                <button class="oe_stat_button" type="object" name="subscriptions_action"
                    icon="fa-book" attrs="{'invisible': [('subscription_count', '=', 0)]}">
                    <field string="Subscriptions" name="subscription_count" widget="statinfo"/>
                </button>
            </div>
        </field>
    </record>

    <record id="view_move_line_form_inherit_sale_subscription" model="ir.ui.view">
        <field name="name">account.move.line.form.inherit</field>
        <field name="model">account.move.line</field>
        <field name="inherit_id" ref="account.view_move_line_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='analytic_tag_ids']" position="after">
                <field name="subscription_id" />
            </xpath>
        </field>
    </record>

    <record id="view_move_form_inherit_sale_subscription" model="ir.ui.view">
        <field name="name">account.move.form.inherit</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form"/>
        <field name="arch" type="xml">
            <xpath expr="//page[@id='invoice_tab']//form//field[@name='analytic_tag_ids']" position="after">
                <field name="subscription_id" />
            </xpath>
        </field>
    </record>
</odoo>
