Merge pull request #320 from odoo-dev/saas-5-website_sale-product-layout-chm

[FIX] website_sale: change template for product and variant selector (type color)
This commit is contained in:
Christophe Matthieu 2014-06-03 18:07:43 +02:00
commit 7770ca8013
5 changed files with 30 additions and 9 deletions

View File

@ -213,6 +213,10 @@ FaceTime HD Camera, 1.2 MP Photos</field>
<field name="attribute_line_ids" eval="[(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2'), ref('product.product_attribute_line_3')])]"/>
</record>
<record id="product_product_4d" model="product.product">
<field name="active" eval="False"/>
</record>
<record id="product_attribute_price_1" model="product.attribute.price">
<field name="product_tmpl_id" ref="product_product_4_product_template"/>
<field name="value_id" ref="product_attribute_value_2"/>

View File

@ -289,6 +289,13 @@
.css_attribute_color input {
margin: 8px;
height: 13px;
opacity: 0;
}
.css_attribute_color.active {
border: 3px ridge #66ee66;
}
.css_attribute_color.active input {
margin: 6px;
}
.js_add_cart_variants option.css_not_available {

View File

@ -251,6 +251,12 @@
input
margin: 8px
height: 13px
opacity: 0
&.active
border: 3px ridge #66ee66
&.active input
margin: 6px
.js_add_cart_variants
option.css_not_available
color: #ccc

View File

@ -62,6 +62,11 @@ $(document).ready(function () {
var dec = value % 1;
$price.html(value + (dec < 0.01 ? ".00" : (dec < 1 ? "0" : "") ));
});
// hightlight selected color
$('.css_attribute_color input').on('change', function (ev) {
$('.css_attribute_color').removeClass("active");
$('.css_attribute_color:has(input:checked)').addClass("active");
});
var $form_var = $('form.js_add_cart_variants');
var variant_ids = $form_var.data("attribute_value_ids");

View File

@ -297,8 +297,8 @@
</t>
<t t-if="a.type == 'color'">
<t t-foreach="a.value_ids" t-as="v">
<label class="css_attribute_color"
t-attf-style="background-color:#{v.color or v.name}">
<label t-attf-style="background-color:#{v.color or v.name}"
t-attf-class="css_attribute_color #{'active' if v.id in attrib_set else ''}">
<input type="checkbox"
name="attrib"
t-att-value="'%s,%s' % (a.id,v.id)"
@ -481,8 +481,8 @@
<ul class="nav nav-pills nav-stacked">
<t t-set="inc" t-value="0"/>
<t t-foreach="variant_id.value_ids" t-as="value_id">
<label class="css_attribute_color"
t-attf-style="background-color:#{value_id.color or value_id.name}">
<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' % variant_id.attribute_id.id"
@ -529,13 +529,12 @@
<template id="product_attributes" inherit_id="website_sale.product" optional="enabled" name="Product attributes">
<xpath expr="//p[@t-field='product.description_sale']" position="after">
<hr t-if="product.attribute_line_ids"/>
<hr t-if="sum([(1 if len(l.value_ids)==1 else 0) for l in product.attribute_line_ids])"/>
<p class="text-muted">
<t t-foreach="product.attribute_line_ids" t-as="variant_id">
<t t-set="inc" t-value="0"/>
<span t-field="variant_id.attribute_id"/>:
<t t-foreach="variant_id.value_ids" t-as="value_id"><t t-if="inc">,</t> <span t-field="value_id.name"/><t t-set="inc" t-value="inc+1"/></t>
<br/>
<t t-if="len(variant_id.value_ids)==1">
<span t-field="variant_id.attribute_id"/>: <span t-field="variant_id.value_ids[0].name"/><br/>
</t>
</t>
</p>
</xpath>