Skip to content

Commit

Permalink
HUMoveToDirectWarehouseService.setFailIfNoHUs
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Nov 11, 2017
1 parent 75f9c51 commit 6608de9
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static HUMoveToDirectWarehouseService newInstance()
private Timestamp _movementDate = null;
private String _description = null;
private boolean _failOnFirstError = false;
private boolean _failIfNoHUs = false; // default false for backward compatibility
private ILoggable loggable = NullLoggable.instance;
private HUEditorView huView;

Expand All @@ -83,13 +84,26 @@ public void move(@NonNull final Iterator<I_M_HU> hus)

//
// Move the HUs, one by one
int countMoved = 0;
while (hus.hasNext())
{
final I_M_HU hu = hus.next();
generateMovement(hu);
countMoved++;
}

if(huView != null)

// Stop here if nothing moved
if (countMoved <= 0)
{
if (isFailIfNoHUs())
{
throw new AdempiereException("@NoSelection@");
}
return;
}

// Invalidate given view, if any
if (huView != null)
{
huView.invalidateAll();
}
Expand Down Expand Up @@ -185,6 +199,17 @@ private final boolean isFailOnFirstError()
return _failOnFirstError;
}

public HUMoveToDirectWarehouseService setFailIfNoHUs(final boolean failIfNoHUs)
{
_failIfNoHUs = failIfNoHUs;
return this;
}

private boolean isFailIfNoHUs()
{
return _failIfNoHUs;
}

public HUMoveToDirectWarehouseService setDocumentsCollection(final DocumentCollection documentsCollection)
{
this.documentsCollection = documentsCollection;
Expand Down Expand Up @@ -217,6 +242,7 @@ private final void notifyHUMoved(final I_M_HU hu)

//
// Remove this HU from the view
// Don't invalidate. We will do it at the end of all processing.
if (huView != null)
{
huView.removeHUIds(ImmutableSet.of(huId));
Expand Down

0 comments on commit 6608de9

Please sign in to comment.