Fixed issue 28722: Not possible to create invoiced receipts for customers created in WebPOS
authorAaron Calero <aaron.calero@openbravo.com>
Fri, 23 Jan 2015 12:21:36 +0100
changeset 25698 aed2a8dd8cc8
parent 25697 b7df49952bd8
child 25699 5cc656afb987
Fixed issue 28722: Not possible to create invoiced receipts for customers created in WebPOS

Modified the event handler used to set the BP currency to work not only on update events, but on save events too.
Now when BPs are saved from the POS, the currency is automatically assigned to these business partners and they can be used to generate invoices.
src/org/openbravo/event/BusinessPartnerEventHandler.java
--- a/src/org/openbravo/event/BusinessPartnerEventHandler.java	Mon Jan 26 13:13:50 2015 +0100
+++ b/src/org/openbravo/event/BusinessPartnerEventHandler.java	Fri Jan 23 12:21:36 2015 +0100
@@ -25,6 +25,7 @@
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
 import org.openbravo.client.kernel.event.EntityNewEvent;
+import org.openbravo.client.kernel.event.EntityPersistenceEvent;
 import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
 import org.openbravo.client.kernel.event.EntityUpdateEvent;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
@@ -39,15 +40,7 @@
     return entities;
   }
 
-  public void onSave(@Observes
-  EntityNewEvent event) {
-    if (!isValidEvent(event)) {
-      return;
-    }
-  }
-
-  public void onUpdate(@Observes
-  EntityUpdateEvent event) {
+  public void onSave(@Observes EntityNewEvent event) {
     if (!isValidEvent(event)) {
       return;
     }
@@ -55,7 +48,15 @@
     setUpdateCurrency(event, bp);
   }
 
-  private void setUpdateCurrency(EntityUpdateEvent event, BusinessPartner bp) {
+  public void onUpdate(@Observes EntityUpdateEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    final BusinessPartner bp = (BusinessPartner) event.getTargetInstance();
+    setUpdateCurrency(event, bp);
+  }
+
+  private void setUpdateCurrency(EntityPersistenceEvent event, BusinessPartner bp) {
     if (bp.getCurrency() == null
         && (bp.getPriceList() != null || bp.getPurchasePricelist() != null)) {