summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2013-07-11 16:24:34 +0200
committerChristophe Matthieu <chm@openerp.com>2013-07-11 16:24:34 +0200
commitffbac75519daef9a08ad5f3aab7a46c8d06a43c3 (patch)
tree71a0a71c6d0c71092c52dae96043afdaeb9596ce /addons
parentd04da544b0bc367a845dd3ffaca5fba08759f28a (diff)
[IMP] website_sale: recommended
bzr revid: chm@openerp.com-20130711142434-natrpfsutm6o66a9
Diffstat (limited to 'addons')
-rw-r--r--addons/website_crm/__openerp__.py4
-rw-r--r--addons/website_sale/__openerp__.py3
-rw-r--r--addons/website_sale/controllers/main.py36
-rw-r--r--addons/website_sale/static/src/css/ecommerce.css26
-rw-r--r--addons/website_sale/static/src/css/ecommerce.sass73
-rw-r--r--addons/website_sale/static/src/js/ecommerce.js2
-rw-r--r--addons/website_sale/views/ecommerce.xml38
7 files changed, 133 insertions, 49 deletions
diff --git a/addons/website_crm/__openerp__.py b/addons/website_crm/__openerp__.py
index 70819e4d631..1f56f9be0af 100644
--- a/addons/website_crm/__openerp__.py
+++ b/addons/website_crm/__openerp__.py
@@ -9,11 +9,11 @@ OpenERP Contact Form
""",
'author': 'OpenERP SA',
'depends': ['website', 'crm'],
- 'installable': True,
- 'auto_install': True,
'data': [
'views/website_crm.xml'
],
'js': ['static/src/js/ecommerce.js'],
'css': ['static/src/css/ecommerce.css'],
+ 'installable': True,
+ 'auto_install': True,
}
diff --git a/addons/website_sale/__openerp__.py b/addons/website_sale/__openerp__.py
index a8366e36a24..9accf2a1b6f 100644
--- a/addons/website_sale/__openerp__.py
+++ b/addons/website_sale/__openerp__.py
@@ -9,10 +9,11 @@ OpenERP E-Commerce
""",
'author': 'OpenERP SA',
'depends': ['website', 'sale', 'point_of_sale'],
- 'installable': True,
'data': [
'views/ecommerce.xml'
],
'js': ['static/src/js/ecommerce.js'],
'css': ['static/src/css/ecommerce.css'],
+ 'installable': True,
+ 'auto_install': True,
}
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index 5aabbf00554..6dd1cac4beb 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -14,7 +14,7 @@ class Ecommerce(http.Controller):
if request.session._uid:
request.httprequest.session['ecommerce_partner_id'] = False
- partner_id = request.registry.get('res.users').browse(cr, uid, uid).partner_id.id
+ partner_id = request.registry.get('res.users').browse(cr, uid, request.session._uid).partner_id.id
else:
partner_id = request.httprequest.session.get('ecommerce_partner_id', False)
if partner_id and not request.registry.get('res.partner').search(cr, uid, [('id', '=', partner_id)]):
@@ -37,7 +37,7 @@ class Ecommerce(http.Controller):
if not order_id:
fields = [k for k, v in order_obj._columns.items()]
order_value = order_obj.default_get(cr, uid, fields, context=context)
- order_value['partner_id'] = partner_id
+ order_value['partner_id'] = partner_id or request.registry.get('res.users').browse(cr, uid, uid).partner_id.id
order_value.update(order_obj.onchange_partner_id(cr, uid, [], uid, context=context)['value'])
order_id = order_obj.create(cr, uid, order_value, context=context)
request.httprequest.session['ecommerce_order'] = order_id
@@ -87,8 +87,12 @@ class Ecommerce(http.Controller):
product_id = product_id and int(product_id) or 0
product_obj = request.registry.get('product.product')
+ line = [line for line in values['order'].order_line if line.product_id.id == product_id]
+ quantity = line and int(line[0].product_uom_qty) or 0
+
values.update({
'product': product_obj.browse(cr, uid, product_id),
+ 'quantity': quantity,
})
html = request.registry.get("ir.ui.view").render(cr, uid, "website_sale.product", values)
return html
@@ -96,7 +100,29 @@ class Ecommerce(http.Controller):
@http.route(['/shop/my_cart'], type='http', auth="admin")
def my_cart(self, offset=0):
cr, uid, partner_id = self.get_cr_uid()
- html = request.registry.get("ir.ui.view").render(cr, uid, "website_sale.my_cart", self.get_values())
+ values = self.get_values()
+
+ my_pids = ",".join([str(line.product_id.id) for line in values['order'].order_line])
+
+ product_ids = []
+ query = """
+ SELECT sol.product_id
+ FROM sale_order_line as my
+ LEFT JOIN sale_order_line as sol
+ ON sol.order_id = my.order_id
+ WHERE my.product_id in (%s)
+ AND sol.product_id not in (%s)
+ GROUP BY sol.product_id
+ ORDER BY COUNT(sol.order_id) DESC
+ LIMIT 8
+ """ % (my_pids, my_pids)
+ cr.execute(query)
+ for p in cr.fetchall():
+ product_ids.append(p[0])
+
+ values["recommended_products"] = request.registry.get('product.product').browse(cr, uid, product_ids)
+
+ html = request.registry.get("ir.ui.view").render(cr, uid, "website_sale.my_cart", values)
return html
@http.route(['/shop/add_cart'], type='http', auth="admin")
@@ -132,7 +158,9 @@ class Ecommerce(http.Controller):
# change and record value
if quantity:
pricelist_id = order.pricelist_id and order.pricelist_id.id or False
- values.update(order_line_obj.product_id_change(cr, uid, [], pricelist_id, product_id, partner_id=partner_id, context=context)['value'])
+ values.update(order_line_obj.product_id_change(cr, uid, [], pricelist_id, product_id,
+ partner_id=partner_id or request.registry.get('res.users').browse(cr, uid, uid).partner_id.id,
+ context=context)['value'])
if order_line_ids:
order_line_obj.write(cr, uid, order_line_ids, values, context=context)
else:
diff --git a/addons/website_sale/static/src/css/ecommerce.css b/addons/website_sale/static/src/css/ecommerce.css
index ff916d2c0f4..5576ac5358b 100644
--- a/addons/website_sale/static/src/css/ecommerce.css
+++ b/addons/website_sale/static/src/css/ecommerce.css
@@ -85,6 +85,9 @@
top: 6px;
text-align: right;
}
+.oe_ecommerce .oe_mycart form input {
+ margin-bottom: 0;
+}
.oe_ecommerce .oe_product {
vertical-align: top;
position: relative;
@@ -100,12 +103,12 @@
-moz-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.1);
}
-.oe_ecommerce .oe_product .oe_button_cart {
+.oe_ecommerce .oe_button_cart {
width: 100%;
font-size: 11px;
position: absolute;
}
-.oe_ecommerce .oe_product .oe_button_cart button {
+.oe_ecommerce .oe_button_cart button {
text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.44);
overflow: hidden;
text-align: center;
@@ -117,14 +120,14 @@
height: 22px;
position: relative;
}
-.oe_ecommerce .oe_product .oe_button_cart button:first-child {
+.oe_ecommerce .oe_button_cart button:first-child {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #aaaaaa), color-stop(100%, #999999));
background: -webkit-linear-gradient(#aaaaaa, #999999);
background: -moz-linear-gradient(#aaaaaa, #999999);
background: -o-linear-gradient(#aaaaaa, #999999);
background: linear-gradient(#aaaaaa, #999999);
}
-.oe_ecommerce .oe_product .oe_button_cart button:first-child span {
+.oe_ecommerce .oe_button_cart button:first-child span {
opacity: 0.8;
filter: alpha(opacity=80);
color: #eb1212;
@@ -133,14 +136,14 @@
top: 3px;
font-size: 20px;
}
-.oe_ecommerce .oe_product .oe_button_cart button:last-child {
+.oe_ecommerce .oe_button_cart button:last-child {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #0088cc), color-stop(100%, #0076b1));
background: -webkit-linear-gradient(#0088cc, #0076b1);
background: -moz-linear-gradient(#0088cc, #0076b1);
background: -o-linear-gradient(#0088cc, #0076b1);
background: linear-gradient(#0088cc, #0076b1);
}
-.oe_ecommerce .oe_product .oe_button_cart button:last-child.btn-success {
+.oe_ecommerce .oe_button_cart button:last-child.btn-success {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #51a351), color-stop(100%, #418541));
background: -webkit-linear-gradient(#51a351, #418541);
background: -moz-linear-gradient(#51a351, #418541);
@@ -155,3 +158,14 @@
margin: 24px;
text-align: center;
}
+.oe_ecommerce .oe_product_detail .oe_button_cart {
+ position: relative;
+ text-align: right;
+}
+.oe_ecommerce .oe_recommended a {
+ margin: 0 3px;
+}
+.oe_ecommerce .oe_recommended img {
+ max-width: 64px;
+ max-height: 64px;
+}
diff --git a/addons/website_sale/static/src/css/ecommerce.sass b/addons/website_sale/static/src/css/ecommerce.sass
index 1bedf005295..963dbd1941a 100644
--- a/addons/website_sale/static/src/css/ecommerce.sass
+++ b/addons/website_sale/static/src/css/ecommerce.sass
@@ -67,6 +67,9 @@
right: 6px
top: 6px
text-align: right
+ form
+ input
+ margin-bottom: 0
.oe_product
vertical-align: top
position: relative
@@ -75,39 +78,49 @@
+border-radius(5px)
border: 1px solid rgba(0,0,0,.1)
+box-shadow(0 0 3px 1px 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
- width: 50px
- height: 22px
- position: relative
- &:first-child
- @include background(linear-gradient(#aaaaaa,#999999))
- span
- opacity: 0.8
- filter: alpha(opacity=80)
- color: rgb(235, 18, 18)
- position: absolute
- left: +18px
- top: 3px
- font-size: 20px
- &:last-child
- @include background(linear-gradient(#0088cc,#0076b1))
- &.btn-success
- @include background(linear-gradient(#51a351, #418541))
+ .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
+ width: 50px
+ height: 22px
+ position: relative
+ &:first-child
+ @include background(linear-gradient(#aaaaaa,#999999))
+ span
+ opacity: 0.8
+ filter: alpha(opacity=80)
+ color: rgb(235, 18, 18)
+ position: absolute
+ left: +18px
+ top: 3px
+ font-size: 20px
+ &:last-child
+ @include background(linear-gradient(#0088cc,#0076b1))
+ &.btn-success
+ @include background(linear-gradient(#51a351, #418541))
form.oe_signup
display: none
.oe_search
form
width: 100%
margin: 24px
- text-align: center \ No newline at end of file
+ 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 \ No newline at end of file
diff --git a/addons/website_sale/static/src/js/ecommerce.js b/addons/website_sale/static/src/js/ecommerce.js
index 9fd040f4215..016f4556033 100644
--- a/addons/website_sale/static/src/js/ecommerce.js
+++ b/addons/website_sale/static/src/js/ecommerce.js
@@ -1,5 +1,5 @@
$(document).ready(function (){
- $('.oe_ecommerce').on('click', '.oe_product .btn-success,.oe_product .btn-primary,.btn-inverse', function (e) {
+ $('.oe_ecommerce').on('click', '.oe_product .btn-success,.oe_product .btn-primary, .oe_product .btn-inverse, .oe_product_detail .btn-success,.oe_product_detail .btn-primary, .oe_product_detail .btn-inverse', function (e) {
var mycart = !!$('.oe_ecommerce .oe_mycart').size();
var $button = $(e.currentTarget);
var link = $button.hasClass('btn-inverse') ? '/shop/remove_cart' : '/shop/add_cart';
diff --git a/addons/website_sale/views/ecommerce.xml b/addons/website_sale/views/ecommerce.xml
index ab9ca74d40d..057bb819714 100644
--- a/addons/website_sale/views/ecommerce.xml
+++ b/addons/website_sale/views/ecommerce.xml
@@ -110,6 +110,20 @@
</div>
</field>
</record>
+
+ <record id="product_recommended" model="ir.ui.view">
+ <field name="name">product_recommended</field>
+ <field name="type">qweb</field>
+ <field name="arch" type="xml">
+ <div class="oe_recommended media well well-small">
+ <h6>Other customers have also take this products:</h6>
+ <t t-foreach="recommended_products or []" t-as="product">
+ <a t-att-href="'/shop/product/%%s' %% product.id"><img t-att-src="'data:image/png;base64,' + product.image"/></a>
+ </t>
+ </div>
+ </field>
+ </record>
+
<!-- product -->
<record id="product" model="ir.ui.view">
@@ -119,11 +133,18 @@
<t t-call="website_sale.page">
<t t-set="title">Product</t>
<t t-set="shop_content">
- <div clas="oe_commerce_product_display">
- <h1><span t-record="product" t-field="name"><t t-esc="product.name"/></span></h1>
- <img class="media-object" t-att-src="'data:image/png;base64,' + product.image"/>
- <div t-record="product" t-field="description_sale"><t t-esc="product.description_sale"/></div>
- <div class="oe_ecommerce_price" t-record="product" t-field="list_price"><t t-esc="product.list_price"/> €</div>
+ <div class="oe_product_detail">
+ <h1><span t-record="product" t-field="name"><t t-esc="product.name"/></span></h1>
+ <div class="oe_button_cart">
+ <button t-att-class="'btn btn-inverse %%s' %% (not quantity and 'oe_hidden' or '')" t-att-data-id="product.id"><span>X</span><i class="icon-shopping-cart icon-large"></i> </button>
+ <button t-att-class="'btn %%s' %% (quantity and 'btn-success' or 'btn-primary')" t-att-data-id="product.id">
+ <i class="icon-shopping-cart icon-large"></i>
+ <span class="oe_txt">(<span class="oe_quantity"><t t-esc="quantity"/></span>)</span>
+ </button>
+ </div>
+ <img class="media-object" t-att-src="'data:image/png;base64,' + product.image"/>
+ <div t-record="product" t-field="description_sale"><t t-esc="product.description_sale"/></div>
+ <div class="oe_ecommerce_price" t-record="product" t-field="list_price"><t t-esc="product.list_price"/> €</div>
</div>
</t>
</t>
@@ -145,6 +166,13 @@
<t t-set="quantity" t-value="int(line.product_uom_qty)"/>
<t t-call="website_sale.product_card"/>
</t>
+ <div class="media well well-small">
+ <form class="navbar-form">
+ <input name="code" type="text" placeholder="Reduction Code..."/>
+ <button class="btn">Submit your Reduction Code</button>
+ </form>
+ </div>
+ <t t-call="website_sale.product_recommended"/>
<t t-call="website_sale.total"/>
<a t-if="order.order_line" href="/shop/customer"><button class="btn btn-success">Next stage</button></a>
</span>