[IMP] website_sale: recommended
bzr revid: chm@openerp.com-20130711143456-dpv0pm9bpeebfq8e
This commit is contained in:
parent
ffbac75519
commit
78fa7ceb12
|
@ -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)
|
||||
|
||||
values["recommended_products"] = 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()
|
||||
|
||||
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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue