Fixed bug 29429: Sales quotation can not be managed if its order is removed.
authorReinaldo Guerra <reinaldo.guerra@peoplewalking.com>
Fri, 27 Mar 2015 15:57:12 -0500
changeset 26420 b509a9c376d0
parent 26419 628d66d2161b
child 26421 908de9299675
Fixed bug 29429: Sales quotation can not be managed if its order is removed.

On delete function in Order event handler, is now defined to reset the quotation status, when the order generated by this quotation is modified and deleted.
Now, it is possible to manage again the original order (quotation) when the order generated is not existent anymore.
src/org/openbravo/event/OrderEventHandler.java
--- a/src/org/openbravo/event/OrderEventHandler.java	Tue Apr 28 12:50:22 2015 +0530
+++ b/src/org/openbravo/event/OrderEventHandler.java	Fri Mar 27 15:57:12 2015 -0500
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2013-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2013-2015 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -27,6 +27,7 @@
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
+import org.openbravo.client.kernel.event.EntityDeleteEvent;
 import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
 import org.openbravo.client.kernel.event.EntityUpdateEvent;
 import org.openbravo.dal.core.OBContext;
@@ -116,4 +117,17 @@
       }
     }
   }
+  
+  public void onDelete(@Observes
+  EntityDeleteEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    final Entity orderEntity = ModelProvider.getInstance().getEntity(Order.ENTITY_NAME);
+    final Property quotationProperty = orderEntity.getProperty(Order.PROPERTY_QUOTATION);
+    Order quotation = (Order) event.getCurrentState(quotationProperty);
+    if (quotation != null){
+      quotation.setDocumentStatus("UE");
+    }
+  }
 }