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 24124 a9b62c65a205
parent 24123 d6b21dfcf62c
child 24125 38100ff86b5a
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	Thu Jan 29 23:14:48 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)) {