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

    <record id="woo_product_fetch_form_view" model="ir.ui.view">
        <field name="name">woo.product.fetch.form</field>
        <field name="model">woo.product.fetch</field>
        <field name="arch" type="xml">
            <form string="Fetch WooCommerce Products">
                <sheet>
                    <group>
                        <field name="instance_id"
                            readonly="state != 'draft'"/>
                        <field name="state" readonly="1"/>
                    </group>

                    <group string="Results"
                        invisible="state == 'draft'">
                        <group>
                            <field name="total_fetched"/>
                            <field name="auto_matched"/>
                        </group>
                        <group>
                            <field name="suggested"/>
                            <field name="unmatched"/>
                        </group>
                    </group>

                    <div class="alert alert-info" role="alert"
                        invisible="state != 'draft'">
                        Select a WooCommerce instance and click Fetch Products. All products and variations will be imported and matched to Odoo products by SKU or name similarity.
                    </div>

                    <div class="alert alert-success" role="alert"
                        invisible="state != 'done'">
                        Fetch complete! Review the product mapping to confirm or adjust suggestions.
                    </div>
                </sheet>

                <footer>
                    <button type="object" name="action_fetch"
                        string="Fetch Products"
                        class="btn-primary"
                        invisible="state != 'draft'"/>
                    <button type="object" name="action_open_mapping"
                        string="Open Product Mapping"
                        class="btn-primary"
                        invisible="state != 'done'"/>
                    <button string="Close" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

    <record id="action_woo_product_fetch" model="ir.actions.act_window">
        <field name="name">Fetch WooCommerce Products</field>
        <field name="res_model">woo.product.fetch</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>

</odoo>
