[FIX] MRP : Cancellation of procurement allowed if it has no moves attached
lp bug: https://launchpad.net/bugs/626695 fixed bzr revid: jvo@tinyerp.com-20100831102045-p9r88j380x515k25
This commit is contained in:
parent
906948cb8d
commit
d7849d322d
|
@ -179,7 +179,7 @@ class procurement_order(osv.osv):
|
|||
@param proc: Current procurement.
|
||||
@return: Quantity or False.
|
||||
"""
|
||||
if proc.product_id.type == 'product':
|
||||
if proc.product_id.type == 'product' and proc.move_id:
|
||||
if proc.move_id.product_uos:
|
||||
return proc.move_id.product_uos_qty
|
||||
return False
|
||||
|
@ -189,7 +189,7 @@ class procurement_order(osv.osv):
|
|||
@param proc: Current procurement.
|
||||
@return: UoS or False.
|
||||
"""
|
||||
if proc.product_id.type == 'product':
|
||||
if proc.product_id.type == 'product' and proc.move_id:
|
||||
if proc.move_id.product_uos:
|
||||
return proc.move_id.product_uos.id
|
||||
return False
|
||||
|
@ -405,7 +405,7 @@ class procurement_order(osv.osv):
|
|||
todo2 = []
|
||||
move_obj = self.pool.get('stock.move')
|
||||
for proc in self.browse(cr, uid, ids):
|
||||
if proc.close_move:
|
||||
if proc.close_move and proc.move_id:
|
||||
if proc.move_id.state not in ('done', 'cancel'):
|
||||
todo2.append(proc.move_id.id)
|
||||
else:
|
||||
|
@ -430,7 +430,7 @@ class procurement_order(osv.osv):
|
|||
"""
|
||||
ok = False
|
||||
for procurement in self.browse(cr, uid, ids):
|
||||
if procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done':
|
||||
if procurement.move_id and procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done':
|
||||
self.action_done(cr, uid, [procurement.id])
|
||||
ok = True
|
||||
return ok
|
||||
|
|
|
@ -1003,7 +1003,7 @@ class stock_picking(osv.osv):
|
|||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
move_obj = self.pool.get('stock.move')
|
||||
if not context:
|
||||
if context is None:
|
||||
context = {}
|
||||
for pick in self.browse(cr, uid, ids, context=context):
|
||||
if pick.state in ['done','cancel']:
|
||||
|
@ -1886,12 +1886,13 @@ class stock_move(osv.osv):
|
|||
def unlink(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
ctx = context.copy()
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.state != 'draft':
|
||||
if move.state != 'draft' and not ctx.get('call_unlink',False):
|
||||
raise osv.except_osv(_('UserError'),
|
||||
_('You can only delete draft moves.'))
|
||||
return super(stock_move, self).unlink(
|
||||
cr, uid, ids, context=context)
|
||||
cr, uid, ids, context=ctx)
|
||||
|
||||
def _create_lot(self, cr, uid, ids, product_id, prefix=False):
|
||||
""" Creates production lot
|
||||
|
|
Loading…
Reference in New Issue