details:   https://code.openbravo.com/erp/devel/pi/rev/0eaef0a7dd5b
changeset: 33092:0eaef0a7dd5b
user:      Asier Martirena <asier.martirena <at> openbravo.com>
date:      Tue Nov 28 15:42:01 2017 +0100
summary:   Fixed issue 37407: Error in server when doing a CL of a layaway with 
a related canceled service

diffstat:

 src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java |  22 
++++++++-
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 1fde3c15b1a6 -r 0eaef0a7dd5b 
src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java
--- a/src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java    
Thu Nov 30 18:31:38 2017 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java    
Tue Nov 28 15:42:01 2017 +0100
@@ -976,10 +976,24 @@
                   && 
linesRelations.containsKey(serviceRelation.getOrderlineRelated().getId())
                   && 
serviceRelation.getOrderlineRelated().getSalesOrder().getId()
                       .equals(oldOrder.getId())) {
-                // A product with a related delivered service (in the same 
ticket) is being
-                // canceled. The relation between the original product and the 
service must be
-                // removed.
-                relationsToRemove.add(serviceRelation);
+                if (serviceRelation.getSalesOrderLine().getSalesOrder().getId()
+                    .equals(oldOrder.getId())) {
+                  // A product with a related delivered service (in the same 
ticket) is being
+                  // canceled. The relation between the original product and 
the service must be
+                  // removed.
+                  relationsToRemove.add(serviceRelation);
+                } else {
+                  if 
(serviceRelation.getSalesOrderLine().getSalesOrder().isCancelled()
+                      && 
serviceRelation.getSalesOrderLine().getSalesOrder().getCancelledorder() != 
null) {
+                    // A product is being canceled that contains a deferred 
service that has been
+                    // already canceled. The relation created from the 
canceled service to the
+                    // original product must be moved to the canceled product.
+                    final OrderLine inverseProductLine = 
OBDal.getInstance().get(OrderLine.class,
+                        
linesRelations.get(serviceRelation.getOrderlineRelated().getId()));
+                    serviceRelation.setOrderlineRelated(inverseProductLine);
+                    OBDal.getInstance().save(serviceRelation);
+                  }
+                }
               } else {
                 // The CL has a service that is being canceled, which is 
related to a product in
                 // other ticket (the product is deferred) or to a product that 
have been delivered

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to