[FIX] website_sale: fix keep query and clean code
This commit is contained in:
parent
45a6012f22
commit
474d63d6b9
|
@ -125,7 +125,8 @@ class website_sale(http.Controller):
|
||||||
if category:
|
if category:
|
||||||
domain += [('product_variant_ids.public_categ_ids', 'child_of', int(category))]
|
domain += [('product_variant_ids.public_categ_ids', 'child_of', int(category))]
|
||||||
|
|
||||||
attrib_values = [map(int,v.split(",")) for v in request.httprequest.args.getlist('attrib') if v]
|
attrib_list = request.httprequest.args.getlist('attrib')
|
||||||
|
attrib_values = [map(int,v.split(",")) for v in attrib_list if v]
|
||||||
attrib_set = set([v[1] for v in attrib_values])
|
attrib_set = set([v[1] for v in attrib_values])
|
||||||
|
|
||||||
if attrib_values:
|
if attrib_values:
|
||||||
|
@ -144,8 +145,7 @@ class website_sale(http.Controller):
|
||||||
if attrib:
|
if attrib:
|
||||||
domain += [('attribute_line_ids.value_ids', 'in', ids)]
|
domain += [('attribute_line_ids.value_ids', 'in', ids)]
|
||||||
|
|
||||||
attrib_query = set(["%s,%s" % (v[0],v[1]) for v in attrib_values])
|
keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_list)
|
||||||
keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_query)
|
|
||||||
|
|
||||||
if not context.get('pricelist'):
|
if not context.get('pricelist'):
|
||||||
context['pricelist'] = int(self.get_pricelist())
|
context['pricelist'] = int(self.get_pricelist())
|
||||||
|
@ -200,11 +200,11 @@ class website_sale(http.Controller):
|
||||||
if category:
|
if category:
|
||||||
category = category_obj.browse(request.cr, request.uid, int(category), context=request.context)
|
category = category_obj.browse(request.cr, request.uid, int(category), context=request.context)
|
||||||
|
|
||||||
attrib_values = [map(int,v.split(",")) for v in request.httprequest.args.getlist('attrib') if v]
|
attrib_list = request.httprequest.args.getlist('attrib')
|
||||||
|
attrib_values = [map(int,v.split(",")) for v in attrib_list if v]
|
||||||
attrib_set = set([v[1] for v in attrib_values])
|
attrib_set = set([v[1] for v in attrib_values])
|
||||||
|
|
||||||
attrib_query = set(["%s,%s" % (v[0],v[1]) for v in attrib_values])
|
keep = QueryURL('/shop', category=category and category.id, search=search, attrib=attrib_list)
|
||||||
keep = QueryURL('/shop', category=category and category.id, search=search, attrib=attrib_query)
|
|
||||||
|
|
||||||
category_ids = category_obj.search(cr, uid, [], context=context)
|
category_ids = category_obj.search(cr, uid, [], context=context)
|
||||||
category_list = category_obj.name_get(cr, uid, category_ids, context=context)
|
category_list = category_obj.name_get(cr, uid, category_ids, context=context)
|
||||||
|
@ -216,8 +216,7 @@ class website_sale(http.Controller):
|
||||||
|
|
||||||
optional_product_ids = []
|
optional_product_ids = []
|
||||||
for p in product.optional_product_ids:
|
for p in product.optional_product_ids:
|
||||||
ctx = context.copy()
|
ctx = dict(context, active_id=p.id)
|
||||||
ctx.update(active_id=p.id)
|
|
||||||
optional_product_ids.append(template_obj.browse(cr, uid, p.id, context=ctx))
|
optional_product_ids.append(template_obj.browse(cr, uid, p.id, context=ctx))
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
|
@ -253,7 +252,7 @@ class website_sale(http.Controller):
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
'order': order,
|
'order': order,
|
||||||
'suggested_products': []
|
'suggested_products': [],
|
||||||
}
|
}
|
||||||
if order:
|
if order:
|
||||||
if not context.get('pricelist'):
|
if not context.get('pricelist'):
|
||||||
|
@ -269,17 +268,9 @@ class website_sale(http.Controller):
|
||||||
if add_qty or set_qty:
|
if add_qty or set_qty:
|
||||||
order._cart_update(product_id=int(product_id), add_qty=int(add_qty), set_qty=int(set_qty))
|
order._cart_update(product_id=int(product_id), add_qty=int(add_qty), set_qty=int(set_qty))
|
||||||
if goto_shop:
|
if goto_shop:
|
||||||
path = "/shop"
|
attrib_list = request.httprequest.args.getlist('attrib')
|
||||||
l = list()
|
keep = QueryURL('/shop', category=kw.get('category'), search=kw.get('search'), attrib=attrib_list)
|
||||||
for k,v in kw.items():
|
return request.redirect( keep() )
|
||||||
if v and k in ["category", "search", "attrib"]:
|
|
||||||
if isinstance(v, list) or isinstance(v, set):
|
|
||||||
l.append(werkzeug.url_encode([(k,i) for i in v]))
|
|
||||||
else:
|
|
||||||
l.append(werkzeug.url_encode([(k,v)]))
|
|
||||||
if l:
|
|
||||||
path += '?' + '&'.join(l)
|
|
||||||
return request.redirect(path)
|
|
||||||
else:
|
else:
|
||||||
return request.redirect("/shop/cart")
|
return request.redirect("/shop/cart")
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
var value = $price.data("price") + parseFloat($label.find(".badge span").text() || 0);
|
var value = $price.data("price") + parseFloat($label.find(".badge span").text() || 0);
|
||||||
var dec = value % 1;
|
var dec = value % 1;
|
||||||
console.log(dec);
|
|
||||||
$price.html(value + (dec < 0.01 ? ".00" : (dec < 1 ? "0" : "") ));
|
$price.html(value + (dec < 0.01 ? ".00" : (dec < 1 ? "0" : "") ));
|
||||||
});
|
});
|
||||||
// hightlight selected color
|
// hightlight selected color
|
||||||
|
|
|
@ -65,12 +65,12 @@
|
||||||
<div class="ribbon btn btn-danger">Sale</div>
|
<div class="ribbon btn btn-danger">Sale</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="oe_product_image">
|
<div class="oe_product_image">
|
||||||
<a itemprop="url" t-attf-href="/shop/product/{{ slug(product) }}/?{{ keep_query('search', 'attrib', category=(category and int(category)), page=(pager['page']['num'] if pager['page']['num']>1 else None)) }}">
|
<a itemprop="url" t-att-href="keep('/shop/product/%s' % slug(product), page=(pager['page']['num'] if pager['page']['num']>1 else None))">
|
||||||
<img itemprop="image" class="img img-responsive" t-attf-src="/website/image/product.template/#{product.id}/image#{'' if product_image_big else '?max_width=300&max_height=300'}"/>
|
<img itemprop="image" class="img img-responsive" t-attf-src="/website/image/product.template/#{product.id}/image#{'' if product_image_big else '?max_width=300&max_height=300'}"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<section>
|
<section>
|
||||||
<h5><strong><a itemprop="name" t-attf-href="/shop/product/{{ slug(product) }}/?{{ keep_query('search', 'attrib', category=(category and int(category)), page=(pager['page']['num'] if pager['page']['num']>1 else None)) }}" t-field="product.name"/></strong></h5>
|
<h5><strong><a itemprop="name" t-att-href="keep('/shop/product/%s' % slug(product), page=(pager['page']['num'] if pager['page']['num']>1 else None))" t-field="product.name"/></strong></h5>
|
||||||
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price" t-if="product.product_variant_ids">
|
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price" t-if="product.product_variant_ids">
|
||||||
<b>
|
<b>
|
||||||
<t t-if="abs(product.lst_price - product.price) > 0.2">
|
<t t-if="abs(product.lst_price - product.price) > 0.2">
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
<div class="container oe_website_sale">
|
<div class="container oe_website_sale">
|
||||||
<div class="products_pager">
|
<div class="products_pager">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form t-att-action="keep('/shop',search=0)" method="get" class="pagination form-inline col-md-3">
|
<form t-att-action="keep('/shop',search='')" method="get" class="pagination form-inline col-md-3">
|
||||||
<t t-call="website_sale.search"/>
|
<t t-call="website_sale.search"/>
|
||||||
</form>
|
</form>
|
||||||
<t t-call="website.pager"/>
|
<t t-call="website.pager"/>
|
||||||
|
@ -536,7 +536,7 @@
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td colspan="4"><h4>Select Your Options</h4></td></tr>
|
<tr t-if="optional_product_ids"><td colspan="4"><h4>Select Your Options</h4></td></tr>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue