[IMP] website_sale display only non empty category in non editable mode
bzr revid: chm@openerp.com-20130924102834-op0bm475w20x35j4
This commit is contained in:
parent
abc273e9a1
commit
51fae1fcf8
|
@ -245,7 +245,7 @@ FaceTime HD Camera, 1.2 MP Photos</field>
|
|||
<field name="name">Bose Mini Bluetooth Speaker</field>
|
||||
<field name="default_code">PC-DEM</field>
|
||||
<field name="categ_id" ref="product_category_4"/>
|
||||
<field name="public_categ_id" ref="services"/>
|
||||
<field name="public_categ_id" ref="Speakers"/>
|
||||
<field name="standard_price">600.0</field>
|
||||
<field name="list_price">900.0</field>
|
||||
<field name="type">consu</field>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
@charset "utf-8";
|
||||
/* THIS CSS FILE IS FOR WEBSITE THEMING CUSTOMIZATION ONLY
|
||||
*
|
||||
* css for editor buttons, openerp widget included in the website and other
|
||||
|
@ -370,6 +371,10 @@ a[data-publish][data-publish='on']:hover .css_published {
|
|||
display: none;
|
||||
}
|
||||
|
||||
.unpublish {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
[data-publish='off']:not(a) > :not([data-publish]) {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
|
|
@ -282,6 +282,8 @@ a[data-publish]
|
|||
&:hover .css_published
|
||||
display: none
|
||||
|
||||
.unpublish
|
||||
opacity: 0.5
|
||||
[data-publish='off']:not(a)
|
||||
>:not([data-publish])
|
||||
opacity: 0.5
|
||||
|
|
|
@ -50,10 +50,22 @@ class Website(osv.osv):
|
|||
class Ecommerce(http.Controller):
|
||||
|
||||
def get_categories(self):
|
||||
domain = [('parent_id', '=', False)]
|
||||
|
||||
category_obj = request.registry.get('product.public.category')
|
||||
category_ids = category_obj.search(request.cr, SUPERUSER_ID, [('parent_id', '=', False)], context=request.context)
|
||||
category_ids = category_obj.search(request.cr, SUPERUSER_ID, domain, context=request.context)
|
||||
categories = category_obj.browse(request.cr, SUPERUSER_ID, category_ids, context=request.context)
|
||||
return categories
|
||||
|
||||
product_obj = request.registry.get('product.product')
|
||||
groups = product_obj.read_group(request.cr, SUPERUSER_ID, [("sale_ok", "=", True), ('website_published', '=', True)], ['public_categ_id'], 'public_categ_id', context=request.context)
|
||||
full_category_ids = [group['public_categ_id'][0] for group in groups if group['public_categ_id']]
|
||||
for cat_id in category_obj.browse(request.cr, SUPERUSER_ID, full_category_ids, context=request.context):
|
||||
while cat_id.parent_id:
|
||||
cat_id = cat_id.parent_id
|
||||
full_category_ids.append(cat_id.id)
|
||||
full_category_ids.append(1)
|
||||
|
||||
return (categories, full_category_ids)
|
||||
|
||||
@website.route(['/shop/', '/shop/category/<cat_id>/', '/shop/category/<cat_id>/page/<int:page>/', '/shop/page/<int:page>/'], type='http', auth="public")
|
||||
def category(self, cat_id=0, page=0, **post):
|
||||
|
@ -63,7 +75,7 @@ class Ecommerce(http.Controller):
|
|||
product_obj = request.registry.get('product.template')
|
||||
|
||||
domain = [("sale_ok", "=", True)]
|
||||
domain += [('website_published', '=', True)]
|
||||
#domain += [('website_published', '=', True)]
|
||||
|
||||
if post.get("search"):
|
||||
domain += ['|', '|', '|',
|
||||
|
@ -84,7 +96,7 @@ class Ecommerce(http.Controller):
|
|||
request.context['pricelist'] = self.get_pricelist()
|
||||
|
||||
values = {
|
||||
'categories': self.get_categories(),
|
||||
'get_categories': self.get_categories,
|
||||
'category_id': cat_id,
|
||||
'products': product_obj.browse(request.cr, SUPERUSER_ID, product_ids, context=request.context),
|
||||
'search': post.get("search"),
|
||||
|
@ -117,7 +129,7 @@ class Ecommerce(http.Controller):
|
|||
'category_id': post.get('category_id') and int(post.get('category_id')) or None,
|
||||
'category': category,
|
||||
'search': post.get("search"),
|
||||
'categories': self.get_categories(),
|
||||
'get_categories': self.get_categories,
|
||||
'category_list': category_list,
|
||||
'product': product,
|
||||
}
|
||||
|
@ -241,7 +253,7 @@ class Ecommerce(http.Controller):
|
|||
suggested_products.append(suggested_ids.pop(index))
|
||||
|
||||
values = {
|
||||
'categories': self.get_categories(),
|
||||
'get_categories': self.get_categories,
|
||||
'suggested_products': prod_obj.browse(request.cr, request.uid, suggested_products, request.context),
|
||||
}
|
||||
return request.website.render("website_sale.mycart", values)
|
||||
|
|
|
@ -103,10 +103,6 @@
|
|||
max-width: 100%;
|
||||
max-height: 140px;
|
||||
}
|
||||
.oe_products .oe_product_list_image img {
|
||||
width: 150px;
|
||||
height: 140px;
|
||||
}
|
||||
.oe_products .oe_product_image {
|
||||
left: 15px;
|
||||
right: 15px;
|
||||
|
|
|
@ -97,10 +97,6 @@
|
|||
border: 1px solid rgba(100, 100, 100, 0.2)
|
||||
max-width: 100%
|
||||
max-height: 140px
|
||||
.oe_product_list_image
|
||||
img
|
||||
width: 150px
|
||||
height: 140px
|
||||
.oe_product_image
|
||||
left: 15px
|
||||
right: 15px
|
||||
|
|
|
@ -68,10 +68,12 @@
|
|||
|
||||
<template id="categories_recursive">
|
||||
<li t-att-class="category.id == category_id and 'active' or ''">
|
||||
<a t-attf-href="/shop/category/#{ category.id }/" t-field="category.name"></a>
|
||||
<a t-att-class="category.id not in categ[1] and 'unpublish' or ''" t-attf-href="/shop/category/#{ category.id }/" t-field="category.name"></a>
|
||||
<ul t-if="category.child_id" class="nav nav-pills nav-stacked nav-hierarchy">
|
||||
<t t-foreach="category.child_id" t-as="category">
|
||||
<t t-call="website_sale.categories_recursive"/>
|
||||
<t t-if="category.id in categ[1] or editable">
|
||||
<t t-call="website_sale.categories_recursive"/>
|
||||
</t>
|
||||
</t>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -111,7 +113,7 @@
|
|||
<div class='row style_default'>
|
||||
<div class="col-md-12" id="products_grid">
|
||||
<t t-foreach="products" t-as="product">
|
||||
<div t-attf-class="col-md-#{ search and 3 or product.website_sizex } oe_product oe-height-#{ search and 2 or product.website_sizey } #{ product.website_product_class}" t-att-data-publish="product.website_published" id="products_layout">
|
||||
<div t-attf-class="col-md-#{ search and 3 or product.website_sizex } oe_product oe-height-#{ search and 2 or product.website_sizey } #{ product.website_product_class}" t-att-data-publish="product.website_published and 'on' or 'off'" id="products_layout">
|
||||
|
||||
<div class="oe_product_description">
|
||||
<a t-attf-href="/shop/product/#{ product.id }/?#{ search and ('search=%s' % search) or ''}#{ category_id and ('&category_id=%s' % category_id) or ''}">
|
||||
|
@ -370,7 +372,8 @@
|
|||
<div class="col-md-3">
|
||||
<ul class="nav nav-pills nav-stacked mt16">
|
||||
<li t-att-class=" '' if category_id else 'active' "><a href="/shop/">All Products</a></li>
|
||||
<t t-foreach="categories" t-as="category">
|
||||
<t t-set="categ" t-value="get_categories()"/>
|
||||
<t t-foreach="categ[0]" t-as="category">
|
||||
<t t-call="website_sale.categories_recursive"/>
|
||||
</t>
|
||||
</ul>
|
||||
|
|
|
@ -31,6 +31,7 @@ class product_pricelist(osv.osv):
|
|||
|
||||
class product_template(osv.osv):
|
||||
_inherit = "product.template"
|
||||
_order = 'website_published,name'
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
'website_description': fields.html('Description for the website'),
|
||||
|
|
Loading…
Reference in New Issue