diff options
| author | Christophe Matthieu <chm@openerp.com> | 2013-07-11 16:34:56 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2013-07-11 16:34:56 +0200 |
| commit | 78fa7ceb12d1fbad4c4a945be5a53b5f4c450b3d (patch) | |
| tree | 45e66ef37da44468744930b63debd02b4f7d52d6 /addons | |
| parent | ffbac75519daef9a08ad5f3aab7a46c8d06a43c3 (diff) | |
[IMP] website_sale: recommended
bzr revid: chm@openerp.com-20130711143456-dpv0pm9bpeebfq8e
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/website_sale/controllers/main.py | 20 | ||||
| -rw-r--r-- | addons/website_sale/views/ecommerce.xml | 3 |
2 files changed, 15 insertions, 8 deletions
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 6dd1cac4beb..8623e72483a 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -93,17 +93,16 @@ class Ecommerce(http.Controller): values.update({ 'product': product_obj.browse(cr, uid, product_id), 'quantity': quantity, + 'recommended_products': self.recommended_product([product_id]), }) html = request.registry.get("ir.ui.view").render(cr, uid, "website_sale.product", values) return html - @http.route(['/shop/my_cart'], type='http', auth="admin") - def my_cart(self, offset=0): + def recommended_product(self, my_pids): + if not my_pids: + return [] cr, uid, partner_id = self.get_cr_uid() - values = self.get_values() - - my_pids = ",".join([str(line.product_id.id) for line in values['order'].order_line]) - + my_pids = str(my_pids)[1:-1] product_ids = [] query = """ SELECT sol.product_id @@ -119,8 +118,15 @@ class Ecommerce(http.Controller): cr.execute(query) for p in cr.fetchall(): 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): + cr, uid, partner_id = self.get_cr_uid() + values = self.get_values() - values["recommended_products"] = request.registry.get('product.product').browse(cr, uid, product_ids) + 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) return html diff --git a/addons/website_sale/views/ecommerce.xml b/addons/website_sale/views/ecommerce.xml index 057bb819714..468a903e8c8 100644 --- a/addons/website_sale/views/ecommerce.xml +++ b/addons/website_sale/views/ecommerce.xml @@ -115,7 +115,7 @@ <field name="name">product_recommended</field> <field name="type">qweb</field> <field name="arch" type="xml"> - <div class="oe_recommended media well well-small"> + <div class="oe_recommended media well well-small" t-if="recommended_products"> <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> @@ -145,6 +145,7 @@ <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> + <t t-call="website_sale.product_recommended"/> </div> </t> </t> |
