<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <menuitem id="menu_loyalty" name="Loyalty"
        parent="website_sale.menu_ecommerce" sequence="4"
        groups="sales_team.group_sale_manager"/>

    <menuitem
        id="menu_discount_loyalty_type_config"
        action="loyalty.loyalty_program_discount_loyalty_action"
        name="Discount &amp; Loyalty"
        parent="website_sale_loyalty.menu_loyalty"
        groups="sales_team.group_sale_manager"
        sequence="50"
    />

    <menuitem
        id="menu_gift_ewallet_type_config"
        action="loyalty.loyalty_program_gift_ewallet_action"
        name="Gift cards &amp; eWallet"
        parent="website_sale_loyalty.menu_loyalty"
        groups="sales_team.group_sale_manager"
        sequence="51"
    />

    <record id="loyalty_program_view_form_inherit_website_sale_loyalty" model="ir.ui.view">
        <field name="name">loyalty.program.view.form.inherit.website.sale.loyalty</field>
        <field name="model">loyalty.program</field>
        <field name="inherit_id" ref="sale_loyalty.loyalty_program_view_form_inherit_sale_loyalty"/>
        <field name="arch" type="xml">
            <xpath expr="//label[@for='available_on']" position="attributes">
                <attribute name="invisible">0</attribute>
            </xpath>
            <xpath expr="//div[@id='o_loyalty_program_availabilities']" position="attributes">
                <attribute name="invisible">0</attribute>
            </xpath>
            <xpath expr="//div[@id='o_loyalty_program_availabilities']" position="inside">
                <span class="d-inline-block">
                    <field name="ecommerce_ok" class="w-auto me-0"/>
                    <label for="ecommerce_ok" string="Website" class="me-3"/>
                </span>
            </xpath>
            <xpath expr="//div[@id='o_loyalty_program_availabilities']" position="after">
                <field name="website_id" attrs="{'invisible': [('ecommerce_ok', '=', False)]}" options="{'no_create': True}" groups="website.group_multi_website" placeholder="All websites"/>
            </xpath>
        </field>
    </record>

    <record id="loyalty_program_view_tree_inherit_website_sale_loyalty" model="ir.ui.view">
        <field name="name">loyalty.program.view.tree.inherit.website.sale.loyalty</field>
        <field name="model">loyalty.program</field>
        <field name="inherit_id" ref="loyalty.loyalty_program_view_tree"/>
        <field name="arch" type="xml">
            <field name="coupon_count_display" position="after">
                <field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/>
            </field>
            <field name="company_id" position="after">
                <button name="action_program_share" string="Share" type="object" icon="fa-share-alt" attrs="{ 'invisible' : [('program_type', '!=', 'promo_code')]}"/>
            </field>
        </field>
    </record>
</odoo>
