<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="assets_frontend" inherit_id="website.assets_frontend" name="Shop">
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/website_sale_add_curve/static/src/js/website_sale_multi_add.js"></script>
            </xpath>
        </template>
        <template id="variant_form" inherit_id="website_sale.variants" name="variants">
            <xpath expr="//t[@t-as='variant_id']" position="replace">
                <t t-foreach="product.attribute_line_ids" t-as="variant_id">
                    <li t-if="len(variant_id.value_ids) &gt; 1">
                        <t t-if="variant_id.attribute_id.type in ['select', 'hidden']">
                            <select class="form-control js_variant_change" t-att-name="'attribute-%s-%s' % (product.id, variant_id.attribute_id.id)">
                                <t t-foreach="variant_id.value_ids" t-as="value_id">
                                    <option t-att-value="value_id.id">
                                        <span t-field="value_id.name"/>
                                        <span t-if="value_id.price_extra">
                                            <t t-esc="value_id.price_extra &gt; 0 and '+' or ''"/><span
                                                t-field="value_id.price_extra"
                                                style="white-space: nowrap;"
                                                t-field-options="{                                &quot;widget&quot;: &quot;monetary&quot;,                                 &quot;from_currency&quot;: &quot;product.company_id.currency_id&quot;,                                &quot;display_currency&quot;: &quot;user_id.partner_id.property_product_pricelist.currency_id&quot;                            }"/>
                                        </span>
                                    </option>
                                </t>
                            </select>
                        </t> 
                        <t t-if="product.product_website_sale_type == False">
                            <input id="attribute_list" type="hidden" t-att-value="attribute_value_ids"></input>
                            <div class="container">
                                <div class="row text-left">
                                    <div class="col-md-12">
                                        <h3 t-field="variant_id.attribute_id.name"></h3>
                                        <table class="table text-center">
                                            <t t-if="variant_id.attribute_id.type == 'radio'">
                                                <ul class="list-unstyled">
                                                    <t t-set="inc" t-value="0"/>
                                                    <t t-foreach="variant_id.value_ids" t-as="value_id">
                                                        <li class="form-group js_attribute_value">
                                                            <tr>
                                                                <td>
                                                                    <span t-field="value_id.name"/>
                                                                    <span class="badge" t-if="value_id.price_extra">
                                                                        <t t-esc="value_id.price_extra &gt; 0 and '+' or ''"/>
                                                                        <span t-field="value_id.price_extra" t-field-options="{                                       &quot;widget&quot;: &quot;monetary&quot;,                                       &quot;from_currency&quot;: &quot;product.company_id.currency_id&quot;,                                       &quot;display_currency&quot;: &quot;user_id.partner_id.property_product_pricelist.currency_id&quot;                                    }"/>
                                                                        </span>
                                                                </td>
                                                                <td>
                                                                   <div class="input-group oe_website_spinner">
                                                                        <span class="input-group-addon">
                                                                            <a t-attf-href="#" class="mb8 js_add_cart_json">
                                                                                <i class="fa fa-minus"/>
                                                                            </a>
                                                                        </span>
                                                                        <input type="text" class="js_quantity form-control" data-min="1" name="add_qty" value="1" id="add_qty"/>
                                                                        <span class="input-group-addon">
                                                                            <a t-attf-href="#" class="mb8 float_left js_add_cart_json">
                                                                                <i class="fa fa-plus"/>
                                                                            </a>
                                                                        </span>
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <button t-att-id="'attribute_%s' % value_id.id" type="button" class="js_variant_change btn btn-primary" t-att-checked="'checked' if not inc else ''" t-att-name="'attribute-%s-%s' % (product.id, variant_id.attribute_id.id)" t-att-value="inc+1">aƱadir a la cesta</button>
                                                                </td>
                                                            </tr>
                                                        </li>
                                                    <t t-set="inc" t-value="inc+1"/></t>
                                                </ul>
                                            </t>
                                        </table>
                                        
                                        <!-- Variante tipo color -->
                                        <t t-if="variant_id.attribute_id.type == 'color'">
                                            <input id="variant_list_color" type="hidden" t-att-value="variant_id.value_ids"></input>
                                            <ul class="list-inline">
                                                <t t-set="inc" t-value="0"/>
                                                <li t-foreach="variant_id.value_ids" t-as="value_id">
                                                    <label t-attf-style="background-color:#{value_id.color or value_id.name}" t-attf-class="css_attribute_color #{'active' if not inc else ''}">
                                                    <input type="radio" t-att-checked="'checked' if not inc else ''" t-att-name="'attribute_%s_%s' % (product.id, variant_id.attribute_id.id)" t-att-value="value_id.id" t-att-title="value_id.name" id="product_color"/>
                                                    </label>
                                                    <t t-set="inc" t-value="inc+1"/>
                                                </li>
                                            </ul>
                                        </t>
                                    </div>
                                </div>
                            </div>
                        </t>               
                        <t t-if="product.product_website_sale_type == True">
                            <input id="attribute_list" type="hidden" t-att-value="attribute_value_ids"></input>
                            <input id="product_curva_qty" type="hidden" t-att-value="product.curva"></input>
                            <div class="container">
                                <div class="row">
                                    <div class="col-md-12">
                                        <t t-if="variant_id.attribute_id.type == 'color'">
                                            <input id="variant_list_color" type="hidden" t-att-value="variant_id.value_ids"></input>
                                            <h2 class="panel-title" t-field="variant_id.attribute_id.name"></h2>
                                            <ul class="list-inline">
                                                <t t-set="inc" t-value="0"/>
                                                <li t-foreach="variant_id.value_ids" t-as="value_id">
                                                    <label t-attf-style="background-color:#{value_id.color or value_id.name}" t-attf-class="css_attribute_color #{'active' if not inc else ''}">
                                                    <input type="radio" t-att-checked="'checked' if not inc else ''" t-att-name="'attribute_%s_%s' % (product.id, variant_id.attribute_id.id)" t-att-value="value_id.id" t-att-title="value_id.name" id="product_color2"/>
                                                    </label>
                                                    <t t-set="inc" t-value="inc+1"/>
                                                </li>
                                            </ul>
                                        </t>
                                        <t t-if="variant_id.attribute_id.type == 'radio'">
                                            <input id="variant_list" t-att-value="variant_id.value_ids" type="hidden"></input>
                                            <div class="panel panel-default">
                                                <div class="panel-heading">Detalle de Curva</div>
                                                <div class="panel-body text-center">
                                                    <h1 class="panel-title" t-field="product.curva"></h1>
                                                </div>
                                            </div>
                                            <h2 class="panel-title" t-field="variant_id.attribute_id.name"></h2>
                                            <table class="table table-condenced text-center">
                                                <ul class="list-unstyled">
                                                    <t t-set="inc" t-value="0"/>
                                                    <tr>
                                                        <t t-foreach="variant_id.value_ids" t-as="value_id">
                                                            <li class="form-group js_attribute_value">
                                                                <td>
                                                                    <span t-field="value_id.name"/>
                                                                </td>
                                                            </li>
                                                        <t t-set="inc" t-value="inc+1"/></t>
                                                    </tr>
                                                </ul>
                                            </table>
                                            <div class="container text-center">
                                                <button id="curva" class="btn btn-primary" href="">Comprar Curva</button>
                                            </div>
                                        </t>
                                    </div>
                                </div>
                            </div>
                        </t>

                    </li>
                </t>
            </xpath>
        </template>

        <!-- Oculta el boton 'add to cart' por defecto del odoo -->
        <template id="product_form" inherit_id="kingfisher_pro.kingfisher_pro_product_details" name="product">
            <xpath expr="//div[@class='add-to-cart']" position="replace">
                <div class="add-to-cart" style="display:none;">
                    <a class="btn cart-btn btn-lg js_check_product a-submit" href="#" id="add_to_cart">
                        <i class="fa fa-shopping-cart"/>Add to Cart</a>
                </div>
            </xpath>
            <xpath expr="//p[@class='css_not_available_msg bg-danger']" position="replace">
                <p style="display:none;" t-if="len(product.product_variant_ids) &gt; 1">Product not available</p>
            </xpath>
        </template>
    </data>
</openerp>