[FIX] [WIP] website_sale: fix crash when having product templates without variant.
authorThibault Delavallée <tde@openerp.com>
Thu, 24 Oct 2013 11:04:53 +0000 (13:04 +0200)
committerThibault Delavallée <tde@openerp.com>
Thu, 24 Oct 2013 11:04:53 +0000 (13:04 +0200)
probably it should not be displayed, but as there does not seem to exist any
clue about what the controller / view should do, I added some protections.

[DOC] added some comments because some methods seems quite weird.

bzr revid: tde@openerp.com-20131024110453-uj4xnrtwst0fdcrb

addons/website_sale/__openerp__.py
addons/website_sale/controllers/main.py
addons/website_sale/views/website_sale.xml

index 634078f..276bd11 100644 (file)
@@ -18,7 +18,7 @@ OpenERP E-Commerce
         'security/website_sale.xml',
     ],
     'demo': [
-        'website_sale_demo.xml',
+        # 'website_sale_demo.xml',
     ],
     'qweb': ['static/src/xml/*.xml'],
     'installable': True,
index 8de0a0b..193bb07 100644 (file)
@@ -113,7 +113,7 @@ class Ecommerce(http.Controller):
         request.context['pricelist'] = self.get_pricelist()
 
         # search for checking of access rules and keep order
-        product_ids = [id for id in product_ids if id in product_obj.search(request.cr, request.uid, [("id", 'in', product_ids)], context=request.context)]
+        product_ids = product_obj.search(request.cr, request.uid, [("id", 'in', product_ids)], context=request.context)
 
         size_ids = {}
         style_ids = style_obj.search(request.cr, SUPERUSER_ID, [('html_class', 'like', 'size_%')], context=request.context)
@@ -212,6 +212,7 @@ class Ecommerce(http.Controller):
                 col += 1
             line += 1
 
+        print bin_packing_list
         return bin_packing_list
 
     def get_products(self, product_ids):
@@ -272,6 +273,9 @@ class Ecommerce(http.Controller):
 
     @website.route(['/shop/', '/shop/page/<int:page>/'], type='http', auth="public", multilang=True)
     def category(self, category=0, attributes="", page=0, **post):
+        # TDE-NOTE: shouldn't we do somethign about product_template without variants ???
+        # TDE-NOTE: is there a reason to call a method category when the route is
+        # basically a shop without category_id speceified ?
 
         if 'promo' in post:
             self.change_pricelist(post.get('promo'))
index 26a484d..eb4c5fc 100644 (file)
@@ -43,7 +43,7 @@
               <b t-field="product.name"/>
           </a>
       </div>
-      <div class="product_price">
+      <div class="product_price" t-if="product.product_variant_ids">
           <b>
               <t t-if="product.product_variant_ids[0].lst_price != product.product_variant_ids[0].price">
                 <del class="text-danger"
                               <br/>
                           </t>
 
-                          <div class="product_price mt16">
+                          <div class="product_price mt16" t-if="product.product_variant_ids">
                               <h4>
                                   <b><span class="oe_price" t-esc="product.product_variant_ids[0].price" /> €</b>