[FIX] [WIP] website_sale: Tries to fix method
authorThibault Delavallée <tde@openerp.com>
Thu, 24 Oct 2013 10:55:24 +0000 (12:55 +0200)
committerThibault Delavallée <tde@openerp.com>
Thu, 24 Oct 2013 10:55:24 +0000 (12:55 +0200)
that does things not commented on things that do not necessarily exist.

Does it hurt you to put some docstrings ?

bzr revid: tde@openerp.com-20131024105524-eattmf2s52ekztn3

addons/website_sale/models/product.py

index e74dcda..9b4c388 100644 (file)
@@ -35,10 +35,17 @@ class product_template(osv.Model):
     _name = 'product.template'
 
     def _website_url(self, cr, uid, ids, field_name, arg, context=None):
-        res = {}
+        """ TDE-NOTE: as someone wrote this method without any clue on about what it
+        does, fixing bugs about product_variant_ids not existing will be done
+        based on the weather, the sun and Lilo's feelings about pigs.
+
+        If you see this comment in trunk, this means that the website branch has
+        been merged without any review, which is quite questionable. """
+        res = dict.fromkeys(ids, '')
         base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
-        for prod in self.browse(cr, uid, ids, context=context):
-            res[prod.id] = "%s/shop/product/%s/" % (base_url, prod.product_variant_ids[0].id)
+        for product in self.browse(cr, uid, ids, context=context):
+            if product.product_variant_ids:
+                res[product.id] = "%s/shop/product/%s/" % (base_url, product.product_variant_ids[0].id)
         return res
 
     _columns = {
@@ -48,7 +55,7 @@ class product_template(osv.Model):
         'suggested_product_ids': fields.one2many('product.template', 'suggested_product_id', 'Suggested Products'),
         'website_size_x': fields.integer('Size X'),
         'website_size_y': fields.integer('Size Y'),
-        'website_style_ids' : fields.many2many('website.product.style','product_website_style_rel', 'product_id', 'style_id', 'Styles'),
+        'website_style_ids': fields.many2many('website.product.style', 'product_website_style_rel', 'product_id', 'style_id', 'Styles'),
         'website_sequence': fields.integer('Sequence', help="Determine the display order in the Website E-commerce"),
         'website_url': fields.function(_website_url, string="Website url"),
     }