diff --git a/addons/website/static/src/css/website.css b/addons/website/static/src/css/website.css index 5959e1c9dda..f47daad8c83 100644 --- a/addons/website/static/src/css/website.css +++ b/addons/website/static/src/css/website.css @@ -175,6 +175,10 @@ h5 { float: right !important; } +.thumbnail { + background: white; +} + /* ---- HACK FOR COVERING UP CK EDITOR BOGUS P INSERTION --- */ .navbar .nav > li > p { margin-bottom: 0px; diff --git a/addons/website/static/src/css/website.sass b/addons/website/static/src/css/website.sass index 7c5f8cb6ce5..c5e45aa288f 100644 --- a/addons/website/static/src/css/website.sass +++ b/addons/website/static/src/css/website.sass @@ -131,6 +131,9 @@ h5 .nav > .pull-right float: right !important //bugfix for flatly theme +.thumbnail + background: white + /* ---- HACK FOR COVERING UP CK EDITOR BOGUS P INSERTION --- */ .navbar .nav > li > p diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index bae6b8b0758..6ffc5036c82 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import math import openerp import simplejson from openerp.addons.web import http @@ -12,7 +13,9 @@ class Ecommerce(http.Controller): def get_categories(self): category_obj = request.registry.get('pos.category') category_ids = category_obj.search(request.cr, openerp.SUPERUSER_ID, [('parent_id', '=', False)]) - return category_obj.browse(request.cr, openerp.SUPERUSER_ID, category_ids) + categories = category_obj.browse(request.cr, openerp.SUPERUSER_ID, category_ids) + print categories + return categories def get_current_order(self): order = self.get_order(request.httprequest.session.get('ecommerce_order_id')) @@ -68,23 +71,46 @@ class Ecommerce(http.Controller): product_ids.append(p[0]) return request.registry.get('product.product').browse(request.cr, request.uid, product_ids) - @http.route(['/shop', '/shop/category/'], type='http', auth="public") - def category(self, cat_id=0, offset=0, **post): - - domain = [("sale_ok", "=", True)] - if post.get("search"): - domain += ['|', '|', ('name', 'ilike', "%%%s%%" % post.get("search")), ('desrequest.cription', 'ilike', "%%%s%%" % post.get("search")), ('pos_categ_id.name', 'ilike', "%%%s%%" % post.get("search"))] - if cat_id: - cat_id = cat_id and int(cat_id) or 0 - domain = [('pos_categ_id.id', 'child_of', cat_id)] + domain + @http.route(['/shop', '/shop/category/', '/shop/category//page/', '/shop/page/'], type='http', auth="public") + def category(self, cat_id=0, page=0, **post): product_obj = request.registry.get('product.product') + + domain = [("sale_ok", "=", True)] + if cat_id: + cat_id = int(cat_id) + domain = [('pos_categ_id.id', 'child_of', cat_id)] + domain + + product_count = len(product_obj.search(request.cr, request.uid, domain)) + page_count = int(math.ceil(product_count / 20.0)) + + #if post.get("search"): + # domain += ['|', '|', ('name', 'ilike', "%%%s%%" % post.get("search")), ('description', 'ilike', "%%%s%%" % post.get("search")), ('pos_categ_id.name', 'ilike', "%%%s%%" % post.get("search"))] + + page = max(1,min(int(page),page_count)) + offset = (page-1) * 20 + + if page_count <= 5 or page <= 3: + pmin = 1 + pmax = min(page_count,5) + elif page >= page_count - 2: + pmin = page_count - 4 + pmax = page_count + else: + pmin = page - 2 + pmax = page + 2 + + pages = range(pmin, pmax+1) + product_ids = product_obj.search(request.cr, request.uid, domain, limit=20, offset=offset) values = { 'current_category': cat_id, 'products': product_obj.browse(request.cr, request.uid, product_ids), 'search': post.get("search"), + 'page_count': page_count, + 'pages': pages, + 'page': page, } html = self.render("website_sale.products", values) return html diff --git a/addons/website_sale/static/src/css/ecommerce.sass b/addons/website_sale/static/src/css/ecommerce.sass deleted file mode 100644 index 510f38816e2..00000000000 --- a/addons/website_sale/static/src/css/ecommerce.sass +++ /dev/null @@ -1,156 +0,0 @@ -@import "compass/css3" - -//.oe_ecommerce - .oe_total - font-size: 13px - margin-top: 10px - td - padding: 5px 10px - table - width: auto - td:last-child - text-align: right - th:last-child - text-align: center - .oe_products - .oe_product - .oe_hidden - visibility: hidden - .pull-left - margin: 0 - float: none - .oe_ecommerce_description - display: none - h4 - text-align: center - +text-shadow(0px 1px 1px rgba(200, 200, 200,.2)) - margin-bottom: 16px - img - max-height: 110px - max-width: 130px - margin: 0 auto - padding-bottom: 14px - text-align: center - display: inline-block - padding: 4px - width: 180px - height: 220px - margin-right: 15px - margin-left: 3px - padding-top: 8px - &:nth-child(3n) - margin-right: 0 - .oe_ecommerce_price - width: 100% - position: absolute - bottom: 44px - +text-shadow(0px 1px 3px rgba(255, 255, 255, 0.7)) - text-align: center - font-size: 25px - span - font-weight: bold - .oe_button_cart - bottom: 5px - left: 0 - .btn-inverse - display: none - .oe_mycart - .oe_product - display: inline-block - width: 250px - margin-left: 0px - float: none - margin-right: 16px - padding: 8px 5px 6px 10px - > .pull-left - width: 84px - height: 64px - img - max-width: 64px - max-height: 64px - margin: auto - .oe_button_cart - position: static - right: 6px - top: 6px - form - input - margin-bottom: 0 - .oe_product - vertical-align: top - position: relative - margin-top: 0 - margin-bottom: 15px - +border-radius(5px) - border: 1px solid rgba(0,0,0,.1) - +box-shadow(0px 1px 3px rgba(0,0,0,.1)) - .oe_button_cart - width: 100% - font-size: 11px - position: absolute - button - +text-shadow(0px 1px 1px rgba(0, 0, 0, 0.44)) - overflow: hidden - text-align: center - font-size: 12px - margin: 0 auto - margin-bottom: 5px - padding: 2px - height: 22px - position: relative - &.btn-inverse - @include background(linear-gradient(#aaaaaa,#999999)) - &.btn-primary - @include background(linear-gradient(#0088cc,#0076b1)) - &.btn-success - @include background(linear-gradient(#51a351, #418541)) - .oe_search - form - width: 100% - margin: 24px - text-align: center - .oe_product_detail - .oe_button_cart - position: relative - text-align: right - .oe_recommended - a - margin: 0 3px - img - max-width: 64px - max-height: 64px - .oe_checkout - .css_required - input, select - //background-color: #d2d2ff !important - h4 - border-bottom: 1px solid #ddd - margin-right: 30px - input:not([type="radio"]):not([type="checkbox"]):not([type="image"]) - height: 20px - input[type="image"] - height: 30px - label - > input:not([type="radio"]):not([type="checkbox"]), > div, > select - display: block - margin-top: 3px - select - margin-top: 3px - > div > input - margin-bottom: 0 - .css_payments - clear: both - .css_payment - position: relative - width: 80px - overflow: hidden - height: 30px - text-align: center - padding: 10px 10px 0 0 - .css_error_payment - width: 100% - height: 100% - position: absolute - top: +O - left: +0 - cursor: pointer diff --git a/addons/website_sale/views/ecommerce.xml b/addons/website_sale/views/ecommerce.xml index dbc2281c39f..03d4062b806 100644 --- a/addons/website_sale/views/ecommerce.xml +++ b/addons/website_sale/views/ecommerce.xml @@ -54,14 +54,8 @@ Shop - Categories
-
- -
- + +
@@ -69,9 +63,20 @@ + +