From c25ad3840732653d1318cac866b7342d6d5fce4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez=20Romanos?=
 <victor.martinez@openbravo.com>
Date: Wed, 16 Sep 2020 14:28:20 +0200
Subject: [PATCH] Fixed ISSUE-45030: Delta SAME expected attribute = original
 task confirmed one

In the case of a Delta SAME we need to make sure the delta task uses exactly the same attribute
that was confirmed in the original task. This is specially useful in receptions where the stock
and attribute are initialized, for other scenarios the change is totally transparent.

This change can't be done when the original task is involved in a swap storage detail, as the internal
swapping process uses the expected/confirmed attributes in a special way.
---
 .../centralbroker/DeltaManagerSame.java               | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/org/openbravo/warehouse/advancedwarehouseoperations/centralbroker/DeltaManagerSame.java b/src/org/openbravo/warehouse/advancedwarehouseoperations/centralbroker/DeltaManagerSame.java
index 4032e791..3a33af78 100644
--- a/src/org/openbravo/warehouse/advancedwarehouseoperations/centralbroker/DeltaManagerSame.java
+++ b/src/org/openbravo/warehouse/advancedwarehouseoperations/centralbroker/DeltaManagerSame.java
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2016-2018 Openbravo S.L.U.
+ * Copyright (C) 2016-2020 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -28,6 +28,15 @@ class DeltaManagerSame {
     final OBAWOTask deltaTask = (OBAWOTask) DalUtil.copy(originalTask, false);
     deltaTask.setExpectedQuantity(deltaQty);
     deltaTask.setConfirmedQuantity(null);
+    /*
+     * Forces the attribute to be always the same for this stock. This is specially useful in
+     * receptions where the stock and attribute are initialized, for other scenarios the change is
+     * totally transparent. In the special case of swapping the storage detail we shouldn't do the
+     * change as it will mess that functionality.
+     */
+    if (originalTask.getSwapWithStorageDetail() == null) {
+      deltaTask.setExpectedAttribute(originalTask.getConfirmedAttribute());
+    }
     deltaTask.setConfirmedAttribute(null);
     deltaTask.setConfirmedLocatorFrom(null);
     deltaTask.setConfirmedLocatorTo(null);
-- 
2.20.1

