[REV] product: unlink method back, no comment about why it has been
removed. It is therefore added back. bzr revid: tde@openerp.com-20140121111421-x35gyqwo9jdpr3d7
This commit is contained in:
parent
93711b0f91
commit
744810bbb4
|
@ -695,6 +695,22 @@ class product_product(osv.osv):
|
|||
'seller_id': fields.function(_calc_seller, type='many2one', relation="res.partner", string='Main Supplier', help="Main Supplier who has highest priority in Supplier List.", multi="seller_info"),
|
||||
}
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
unlink_ids = []
|
||||
unlink_product_tmpl_ids = []
|
||||
for product in self.browse(cr, uid, ids, context=context):
|
||||
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)
|
||||
if not other_product_ids:
|
||||
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 res
|
||||
|
||||
def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id):
|
||||
if uom_id and uom_po_id:
|
||||
uom_obj=self.pool.get('product.uom')
|
||||
|
|
Loading…
Reference in New Issue