summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2013-03-25 16:37:06 +0100
committerThibault Delavallée <tde@openerp.com>2013-03-25 16:37:06 +0100
commitbe97933e77374e0ed2e8b2ccbc17b723e7c2abff (patch)
tree3ff6c47be5c8d0fabc55375e444a68707e36844a
parent1b60aa2d27c5caef1bdfaea6aae084df8e7821c8 (diff)
[FIX] product: unlinking products was not possible due to already-deleted product that leads to a crash, therefore reverting the unlink.
bzr revid: tde@openerp.com-20130325153706-kykjhcaaw0z8tm23
-rw-r--r--addons/product/product.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/product/product.py b/addons/product/product.py
index 33225c92c6f..82b37f7b9e8 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -588,10 +588,13 @@ class product_product(osv.osv):
# 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)
if not other_product_ids:
- unlink_product_tmpl_ids.append(tmpl_id)
+ unlink_product_tmpl_ids.append(tmpl_id)
unlink_ids.append(product.id)
+ res = super(product_product, self).unlink(cr, uid, unlink_ids, context=context)
+ # delete templates after calling super, as deleting template could lead to deleting
+ # products due to ondelete='cascade'
self.pool.get('product.template').unlink(cr, uid, unlink_product_tmpl_ids, context=context)
- return super(product_product, self).unlink(cr, uid, unlink_ids, context=context)
+ return res
def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id):
if uom_id and uom_po_id: