[FIX] stock: picking: do_unreserve
When a scrapped move is part of an open picking, it was not possible to unreserve the picking. A scrapped move is done and scrapped ; this combination should be allowed. opw-1835186
This commit is contained in:
@@ -486,9 +486,19 @@ class StockMove(models.Model):
|
||||
}
|
||||
|
||||
def _do_unreserve(self):
|
||||
if any(move.state in ('done', 'cancel') for move in self):
|
||||
raise UserError(_('Cannot unreserve a done move'))
|
||||
self.mapped('move_line_ids').unlink()
|
||||
moves_to_unreserve = self.env['stock.move']
|
||||
for move in self:
|
||||
if move.state == 'cancel':
|
||||
# We may have cancelled move in an open picking in a "propagate_cancel" scenario.
|
||||
continue
|
||||
if move.state == 'done':
|
||||
if move.scrapped:
|
||||
# We may have done move in an open picking in a scrap scenario.
|
||||
continue
|
||||
else:
|
||||
raise UserError(_('Cannot unreserve a done move'))
|
||||
moves_to_unreserve |= move
|
||||
moves_to_unreserve.mapped('move_line_ids').unlink()
|
||||
return True
|
||||
|
||||
def _push_apply(self):
|
||||
|
||||
Reference in New Issue
Block a user