[FIX] website info view remove optional tag
[odoo/odoo.git] / addons / product / product.py
index 32b3a0b..8c0a919 100644 (file)
@@ -395,6 +395,7 @@ class product_attribute_price(osv.osv):
 
 class product_attribute_line(osv.osv):
     _name = "product.attribute.line"
+    _rec_name = 'attribute_id'
     _columns = {
         'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade'),
         'attribute_id': fields.many2one('product.attribute', 'Attribute', required=True, ondelete='restrict'),
@@ -423,13 +424,7 @@ class product_template(osv.osv):
         return self._is_product_variant_impl(cr, uid, ids, name, arg, context=context)
 
     def _is_product_variant_impl(self, cr, uid, ids, name, arg, context=None):
-        prod = self.pool.get('product.product')
-        res = dict.fromkeys(ids, False)
-        ctx = dict(context, active_test=True)
-        for product in self.browse(cr, uid, ids, context=context):
-            res[product.id] = prod.search(cr, uid, [('product_tmpl_id','=',product.id)], context=ctx, count=True) == 1
-        return res
-
+        return dict.fromkeys(ids, False)
 
     def _product_template_price(self, cr, uid, ids, name, arg, context=None):
         plobj = self.pool.get('product.pricelist')
@@ -909,7 +904,7 @@ class product_product(osv.osv):
         'partner_ref' : fields.function(_product_partner_ref, type='char', string='Customer ref'),
         'default_code' : fields.char('Internal Reference', select=True),
         'active': fields.boolean('Active', help="If unchecked, it will allow you to hide the product without removing it."),
-        'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade", select=True),
+        'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade", select=True, auto_join=True),
         'ean13': fields.char('EAN13 Barcode', size=13, help="International Article Number used for product identification."),
         'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', store={
             'product.template': (_get_name_template_ids, ['name'], 10),
@@ -942,6 +937,9 @@ class product_product(osv.osv):
         unlink_ids = []
         unlink_product_tmpl_ids = []
         for product in self.browse(cr, uid, ids, context=context):
+            # Check if product still exists, in case it has been unlinked by unlinking its template
+            if not product.exists():
+                continue
             tmpl_id = product.product_tmpl_id.id
             # Check if the product is last product of this template
             other_product_ids = self.search(cr, uid, [('product_tmpl_id', '=', tmpl_id), ('id', '!=', product.id)], context=context)
@@ -984,7 +982,7 @@ class product_product(osv.osv):
 
         def _name_get(d):
             name = d.get('name','')
-            code = d.get('default_code',False)
+            code = context.get('display_default_code', True) and d.get('default_code',False) or False
             if code:
                 name = '[%s] %s' % (code,name)
             return (d['id'], name)