Override Unlink function to delete only Draft Procurement,Stock Moves,Stock Picking,Purchase Order
bzr revid: ruchakpatel@gmail.com-20081006105620-6jjkeb92qy1vwio4
This commit is contained in:
parent
7a375e05cd
commit
cff93674bb
|
@ -727,6 +727,18 @@ class mrp_procurement(osv.osv):
|
|||
'close_move': lambda *a: 0,
|
||||
'procure_method': lambda *a: 'make_to_order',
|
||||
}
|
||||
|
||||
def unlink(self, cr, uid, ids):
|
||||
procurements = self.read(cr, uid, ids, ['state'])
|
||||
unlink_ids = []
|
||||
for s in procurements:
|
||||
if s['state'] in ['draft','cancel']:
|
||||
unlink_ids.append(s['id'])
|
||||
else:
|
||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!' % s['state']))
|
||||
osv.osv.unlink(self, cr, uid, unlink_ids)
|
||||
return True
|
||||
|
||||
def check_product(self, cr, uid, ids):
|
||||
for procurement in self.browse(cr, uid, ids):
|
||||
if procurement.product_id.type in ('product', 'consu'):
|
||||
|
|
|
@ -206,7 +206,18 @@ class purchase_order(osv.osv):
|
|||
_name = "purchase.order"
|
||||
_description = "Purchase order"
|
||||
_order = "name desc"
|
||||
|
||||
|
||||
def unlink(self, cr, uid, ids):
|
||||
purchase_orders = self.read(cr, uid, ids, ['state'])
|
||||
unlink_ids = []
|
||||
for s in purchase_orders:
|
||||
if s['state'] in ['draft','cancel']:
|
||||
unlink_ids.append(s['id'])
|
||||
else:
|
||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state']))
|
||||
osv.osv.unlink(self, cr, uid, unlink_ids)
|
||||
return True
|
||||
|
||||
def button_dummy(self, cr, uid, ids, context={}):
|
||||
return True
|
||||
|
||||
|
|
|
@ -406,7 +406,17 @@ class stock_picking(osv.osv):
|
|||
#def copy(self, cr, uid, id, data=None, context={}):
|
||||
# data = data or {}
|
||||
# return super(stock_picking, self).copy(cr, uid, id, data, context)
|
||||
|
||||
def unlink(self, cr, uid, ids):
|
||||
pickings = self.read(cr, uid, ids, ['state'])
|
||||
unlink_ids = []
|
||||
for s in pickings:
|
||||
if s['state'] in ['draft','cancel']:
|
||||
unlink_ids.append(s['id'])
|
||||
else:
|
||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Picking(s) which are in %s State!' % s['state']))
|
||||
osv.osv.unlink(self, cr, uid, unlink_ids)
|
||||
return True
|
||||
|
||||
def onchange_partner_in(self, cr, uid, context, partner_id=None):
|
||||
sid = self.pool.get('res.partner.address').browse(cr, uid, partner_id, context).partner_id.property_stock_supplier.id
|
||||
return { }
|
||||
|
@ -874,6 +884,17 @@ class stock_move(osv.osv):
|
|||
'You try to assign a lot which is not from the same product',
|
||||
['prodlot_id'])]
|
||||
|
||||
# def unlink(self, cr, uid, ids):
|
||||
# moves = self.read(cr, uid, ids, ['state'])
|
||||
# unlink_ids = []
|
||||
# for s in moves:
|
||||
# if s['state'] in ['draft','cancel']:
|
||||
# unlink_ids.append(s['id'])
|
||||
# else:
|
||||
# raise osv.except_osv(_('Invalid action !'), _('Cannot delete Stock Move(s) which are in %s State!' % s['state']))
|
||||
# osv.osv.unlink(self, cr, uid, unlink_ids)
|
||||
# return True
|
||||
|
||||
def _default_location_destination(self, cr, uid, context={}):
|
||||
if context.get('move_line', []):
|
||||
return context['move_line'][0][2]['location_dest_id']
|
||||
|
|
Loading…
Reference in New Issue