[IMP] website_sale: search
bzr revid: chm@openerp.com-20130710150339-m5rn3vzd52vs4ko6
This commit is contained in:
parent
5f0b723525
commit
6a16ccfada
|
@ -12,6 +12,7 @@ class Ecommerce(http.Controller):
|
|||
def get_cr_uid(self):
|
||||
cr = request.cr
|
||||
uid = request.session._uid or openerp.SUPERUSER_ID
|
||||
# todo => admin => request.uid and login => request.session.uid ; auth="admin"
|
||||
if uid != 1:
|
||||
request.httprequest.session['ecommerce_partner_id'] = False
|
||||
partner_id = None
|
||||
|
@ -57,20 +58,27 @@ class Ecommerce(http.Controller):
|
|||
return values
|
||||
|
||||
@http.route(['/shop', '/shop/category/<cat_id>'], type='http', auth="db")
|
||||
def category(self, cat_id=0, offset=0):
|
||||
def category(self, cat_id=0, offset=0, **post):
|
||||
values = self.get_values()
|
||||
cr, uid, partner_id = self.get_cr_uid()
|
||||
|
||||
cat_id = cat_id and int(cat_id) or 0
|
||||
domain = []
|
||||
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"))]
|
||||
if cat_id:
|
||||
cat_id = cat_id and int(cat_id) or 0
|
||||
domain = [('pos_categ_id.id', 'child_of', cat_id)] + domain
|
||||
|
||||
category_obj = request.registry.get('pos.category')
|
||||
product_obj = request.registry.get('product.product')
|
||||
category_ids = category_obj.search(cr, openerp.SUPERUSER_ID, [('parent_id', '=', False)])
|
||||
product_ids = product_obj.search(cr, openerp.SUPERUSER_ID, cat_id and [('pos_categ_id.id', 'child_of', cat_id)] or [(1, '=', 1)], limit=20, offset=offset)
|
||||
product_ids = product_obj.search(cr, openerp.SUPERUSER_ID, domain or [(1, '=', 1)], limit=20, offset=offset)
|
||||
|
||||
values.update({
|
||||
'current_category': cat_id,
|
||||
'categories': category_obj.browse(cr, openerp.SUPERUSER_ID, category_ids),
|
||||
'products': product_obj.browse(cr, openerp.SUPERUSER_ID, product_ids),
|
||||
'search': post.get("search"),
|
||||
})
|
||||
html = request.registry.get("ir.ui.view").render(cr, uid, "website_sale.products", values)
|
||||
return html
|
||||
|
|
|
@ -24,9 +24,10 @@
|
|||
text-align: center;
|
||||
display: inline-block;
|
||||
padding: 5px;
|
||||
width: 170px;
|
||||
width: 180px;
|
||||
height: 220px;
|
||||
margin-right: 15px;
|
||||
margin-left: 3px;
|
||||
}
|
||||
.oe_ecommerce .oe_products .oe_product .oe_hidden {
|
||||
visibility: hidden;
|
||||
|
@ -49,6 +50,9 @@
|
|||
margin: 0 auto;
|
||||
padding-bottom: 14px;
|
||||
}
|
||||
.oe_ecommerce .oe_products .oe_product:nth-child(3n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
.oe_ecommerce .oe_products .oe_product .oe_ecommerce_price {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
|
@ -142,3 +146,8 @@
|
|||
.oe_ecommerce form.oe_signup {
|
||||
display: none;
|
||||
}
|
||||
.oe_ecommerce .oe_search form {
|
||||
width: 100%;
|
||||
margin: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
@ -35,9 +35,12 @@
|
|||
text-align: center
|
||||
display: inline-block
|
||||
padding: 5px
|
||||
width: 170px
|
||||
width: 180px
|
||||
height: 220px
|
||||
margin-right: 15px
|
||||
margin-left: 3px
|
||||
&:nth-child(3n)
|
||||
margin-right: 0
|
||||
.oe_ecommerce_price
|
||||
width: 100%
|
||||
position: absolute
|
||||
|
@ -99,4 +102,9 @@
|
|||
&.btn-success
|
||||
@include background(linear-gradient(#51a351, #418541))
|
||||
form.oe_signup
|
||||
display: none
|
||||
display: none
|
||||
.oe_search
|
||||
form
|
||||
width: 100%
|
||||
margin: 24px
|
||||
text-align: center
|
|
@ -72,6 +72,12 @@
|
|||
<t t-call="website_sale.page">
|
||||
<t t-set="title">Product</t>
|
||||
<t t-set="shop_content">
|
||||
<div class="oe_search">
|
||||
<form action="/shop" method="get" class="navbar-search">
|
||||
<input type="text" name="search" class="search-query span4" placeholder="Search" t-att-value="search or ''"/>
|
||||
<button type="submit" class="btn">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
<span class="oe_products">
|
||||
<t t-foreach="products" t-as="product">
|
||||
<t t-set="quantity" t-value="([int(line.product_uom_qty) for line in (order.order_line or []) if line.product_id.id == product.id] + [0])[0]"/>
|
||||
|
|
Loading…
Reference in New Issue