diff options
| author | Christophe Matthieu <chm@openerp.com> | 2013-07-12 10:57:14 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2013-07-12 10:57:14 +0200 |
| commit | e52bdd38385e5c6a2866a3c1452d4834f072fbc3 (patch) | |
| tree | 5406f10d52693647e1bd8852b4458e115eb2e922 /addons | |
| parent | 78fa7ceb12d1fbad4c4a945be5a53b5f4c450b3d (diff) | |
[IMP] website_sale: promotionnal code
bzr revid: chm@openerp.com-20130712085714-rmryh2pebnv8nsjk
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/website_sale/__init__.py | 1 | ||||
| -rw-r--r-- | addons/website_sale/__openerp__.py | 3 | ||||
| -rw-r--r-- | addons/website_sale/controllers/main.py | 15 | ||||
| -rw-r--r-- | addons/website_sale/static/src/css/ecommerce.css | 21 | ||||
| -rw-r--r-- | addons/website_sale/static/src/css/ecommerce.sass | 21 | ||||
| -rw-r--r-- | addons/website_sale/views/ecommerce.xml | 18 |
6 files changed, 36 insertions, 43 deletions
diff --git a/addons/website_sale/__init__.py b/addons/website_sale/__init__.py index ee5959455ad..e6dc1baf9d5 100644 --- a/addons/website_sale/__init__.py +++ b/addons/website_sale/__init__.py @@ -1 +1,2 @@ import controllers +import pricelist diff --git a/addons/website_sale/__openerp__.py b/addons/website_sale/__openerp__.py index 9accf2a1b6f..863c53b2329 100644 --- a/addons/website_sale/__openerp__.py +++ b/addons/website_sale/__openerp__.py @@ -10,7 +10,8 @@ OpenERP E-Commerce 'author': 'OpenERP SA', 'depends': ['website', 'sale', 'point_of_sale'], 'data': [ - 'views/ecommerce.xml' + 'views/ecommerce.xml', + 'views/pricelist.xml' ], 'js': ['static/src/js/ecommerce.js'], 'css': ['static/src/css/ecommerce.css'], diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 8623e72483a..93faee68c0f 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -80,7 +80,7 @@ class Ecommerce(http.Controller): return html @http.route(['/shop/product/<product_id>'], type='http', auth="admin") - def product(self, cat_id=0, product_id=0, offset=0): + def product(self, cat_id=0, product_id=0): values = self.get_values() cr, uid, partner_id = self.get_cr_uid() @@ -120,15 +120,22 @@ class Ecommerce(http.Controller): product_ids.append(p[0]) return request.registry.get('product.product').browse(cr, uid, product_ids) - @http.route(['/shop/my_cart'], type='http', auth="admin") - def my_cart(self, offset=0): + @http.route(['/shop/mycart'], type='http', auth="admin") + def mycart(self, **post): cr, uid, partner_id = self.get_cr_uid() values = self.get_values() + if post.get('code'): + pricelist_obj = request.registry.get('product.pricelist') + order_obj = request.registry.get('sale.order') + pricelist_ids = pricelist_obj.search(cr, uid, [('code', '=', post.get('code'))]) + if pricelist_ids: + values["order"].write({'pricelist_id': pricelist_ids[0]}) + my_pids = [line.product_id.id for line in values['order'].order_line] values["recommended_products"] = self.recommended_product(my_pids) - html = request.registry.get("ir.ui.view").render(cr, uid, "website_sale.my_cart", values) + html = request.registry.get("ir.ui.view").render(cr, uid, "website_sale.mycart", values) return html @http.route(['/shop/add_cart'], type='http', auth="admin") diff --git a/addons/website_sale/static/src/css/ecommerce.css b/addons/website_sale/static/src/css/ecommerce.css index 5576ac5358b..fcdf0cb6d22 100644 --- a/addons/website_sale/static/src/css/ecommerce.css +++ b/addons/website_sale/static/src/css/ecommerce.css @@ -23,7 +23,7 @@ .oe_ecommerce .oe_products .oe_product { text-align: center; display: inline-block; - padding: 5px; + padding: 4px; width: 180px; height: 220px; margin-right: 15px; @@ -68,6 +68,9 @@ bottom: 5px; left: 0; } +.oe_ecommerce .oe_products .oe_product .oe_button_cart .btn-inverse { + display: none; +} .oe_ecommerce .oe_mycart .oe_product { padding: 3px 5px 6px 10px; } @@ -116,34 +119,24 @@ margin: 0 auto; margin-bottom: 5px; padding: 2px; - width: 50px; height: 22px; position: relative; } -.oe_ecommerce .oe_button_cart button:first-child { +.oe_ecommerce .oe_button_cart button.btn-inverse { 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_button_cart button:first-child span { - opacity: 0.8; - filter: alpha(opacity=80); - color: #eb1212; - position: absolute; - left: 18px; - top: 3px; - font-size: 20px; -} -.oe_ecommerce .oe_button_cart button:last-child { +.oe_ecommerce .oe_button_cart button.btn-primary { 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_button_cart button:last-child.btn-success { +.oe_ecommerce .oe_button_cart button.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); diff --git a/addons/website_sale/static/src/css/ecommerce.sass b/addons/website_sale/static/src/css/ecommerce.sass index 963dbd1941a..fc1ca3b5722 100644 --- a/addons/website_sale/static/src/css/ecommerce.sass +++ b/addons/website_sale/static/src/css/ecommerce.sass @@ -34,7 +34,7 @@ padding-bottom: 14px text-align: center display: inline-block - padding: 5px + padding: 4px width: 180px height: 220px margin-right: 15px @@ -53,6 +53,8 @@ .oe_button_cart bottom: 5px left: 0 + .btn-inverse + display: none .oe_mycart .oe_product padding: 3px 5px 6px 10px @@ -90,23 +92,14 @@ margin: 0 auto margin-bottom: 5px padding: 2px - width: 50px height: 22px position: relative - &:first-child + &.btn-inverse @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 + &.btn-primary @include background(linear-gradient(#0088cc,#0076b1)) - &.btn-success - @include background(linear-gradient(#51a351, #418541)) + &.btn-success + @include background(linear-gradient(#51a351, #418541)) form.oe_signup display: none .oe_search diff --git a/addons/website_sale/views/ecommerce.xml b/addons/website_sale/views/ecommerce.xml index 468a903e8c8..2f691a73c18 100644 --- a/addons/website_sale/views/ecommerce.xml +++ b/addons/website_sale/views/ecommerce.xml @@ -9,7 +9,7 @@ <field name="arch" type="xml"> <data> <xpath expr="(//header//li)[last()]" position="after"> - <li class="pull-right"><a href="/shop/my_cart"><i class="icon-shopping-cart icon-large"></i> My cart</a></li> + <li class="pull-right"><a href="/shop/mycart"><i class="icon-shopping-cart icon-large"></i> My cart</a></li> <li class="pull-right"><a href="/shop">Shop</a></li> </xpath> <xpath expr="//footer/div/div/div[3]" position="inside"> @@ -100,9 +100,8 @@ <div class="oe_ecommerce_description" t-record="product" t-field="description_sale"><t t-esc="product.description_sale"/></div> <div class="oe_ecommerce_price"><span><span t-record="product" t-field="list_price"><t t-esc="product.list_price"/></span>€</span></div> <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> + <button t-att-class="'btn btn-inverse %%s' %% (not quantity and 'oe_hidden' or '')" t-att-data-id="product.id">Remove one</button> + <button t-att-class="'btn %%s' %% (quantity and 'btn-success' or 'btn-primary')" t-att-data-id="product.id">Add to cart <span class="oe_txt">(<span class="oe_quantity"><t t-esc="quantity"/></span>)</span> </button> </div> @@ -136,9 +135,8 @@ <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> + <button t-att-class="'btn btn-inverse %%s' %% (not quantity and 'oe_hidden' or '')" t-att-data-id="product.id">Remove one</button> + <button t-att-class="'btn %%s' %% (quantity and 'btn-success' or 'btn-primary')" t-att-data-id="product.id">Add to cart <span class="oe_txt">(<span class="oe_quantity"><t t-esc="quantity"/></span>)</span> </button> </div> @@ -154,8 +152,8 @@ <!-- Page Shop my cart --> - <record id="my_cart" model="ir.ui.view"> - <field name="name">my_cart</field> + <record id="mycart" model="ir.ui.view"> + <field name="name">mycart</field> <field name="type">qweb</field> <field name="arch" type="xml"> <t t-call="website_sale.page"> @@ -168,7 +166,7 @@ <t t-call="website_sale.product_card"/> </t> <div class="media well well-small"> - <form class="navbar-form"> + <form action="/shop/mycart" class="navbar-form"> <input name="code" type="text" placeholder="Reduction Code..."/> <button class="btn">Submit your Reduction Code</button> </form> |
