# HG changeset patch
# User Mario Castello <mario.castello@peoplewalking.com>
# Date 1488390209 21600
#      mié mar 01 11:43:29 2017 -0600
# Node ID 72a1e26beb4d6edbca966509dc9c7a8da44a8e37
# Parent  c04938eafe0f8067af8fcad75f5ea21a7dfacac6
Fixed issue 0035372: [SER-QA 2497] Overlapping popup appears in Web POS after paying with check duplicate.

- Create new event checkOpenDrawer to replaced the closed event when call the OpenDrawer
- Call the event checkOpenDrawer when the PreOrderSaveHook finish the execution
- The onclosed event is executed before the PreOrderSaveHook and if the hook failed it is unnecessary call the OpenDrawer

diff --git a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
--- a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
+++ b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
@@ -115,6 +115,8 @@
             return true;
           }
 
+          receipt.trigger('checkOpenDrawer');
+
           if (OB.UTIL.RfidController.isRfidConfigured()) {
             OB.UTIL.RfidController.processRemainingCodes(receipt);
             OB.UTIL.RfidController.updateEpcBuffers();
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -312,7 +312,7 @@
       }
     };
 
-    receipt.on('closed', function () {
+    receipt.on('checkOpenDrawer', function () {
       me.checkOpenDrawer();
     });
 
