# HG changeset patch
# User Kepa Choperena <kepa.choperena@openbravo.com>
# Date 1571046844 -7200
#      Mon Oct 14 11:54:04 2019 +0200
# Node ID e66f4f20079fb7881ce41dab2e3dba7ed15c8c0c
# Parent  ad51801220f84d61dd9e247fb91485ef9c73f7f4
Created a new process controller for the 'Open Receipt' process.
Also, updated new receipt and delete receipt buttons to listen the 'openReceipt' process controller

diff --git a/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml b/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml
--- a/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml
+++ b/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml
@@ -47,6 +47,18 @@
 <!--69B6AB22CF63415EA017CE4E830A571B-->  <TERMINALLOG><![CDATA[Y]]></TERMINALLOG>
 <!--69B6AB22CF63415EA017CE4E830A571B--></OBMOBC_PROCESS_DEFINITION>
 
+<!--73E19B41B35846BC9A8D2BA8913F7676--><OBMOBC_PROCESS_DEFINITION>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <OBMOBC_PROCESS_DEFINITION_ID><![CDATA[73E19B41B35846BC9A8D2BA8913F7676]]></OBMOBC_PROCESS_DEFINITION_ID>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <SEARCHKEY><![CDATA[openReceipt]]></SEARCHKEY>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <NAME><![CDATA[Open Receipt]]></NAME>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <DESCRIPTION><![CDATA[When loading the order using the 'Open Receipt' functionality]]></DESCRIPTION>
+<!--73E19B41B35846BC9A8D2BA8913F7676-->  <TERMINALLOG><![CDATA[Y]]></TERMINALLOG>
+<!--73E19B41B35846BC9A8D2BA8913F7676--></OBMOBC_PROCESS_DEFINITION>
+
 <!--7583C2FA2D3D4FB2A980684AD2ABDCFC--><OBMOBC_PROCESS_DEFINITION>
 <!--7583C2FA2D3D4FB2A980684AD2ABDCFC-->  <OBMOBC_PROCESS_DEFINITION_ID><![CDATA[7583C2FA2D3D4FB2A980684AD2ABDCFC]]></OBMOBC_PROCESS_DEFINITION_ID>
 <!--7583C2FA2D3D4FB2A980684AD2ABDCFC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
@@ -55,7 +55,7 @@
   handlers: {
     onLeftToolbarDisabled: 'disabledButton'
   },
-  processesToListen: ['calculateReceipt', 'addProduct'],
+  processesToListen: ['calculateReceipt', 'addProduct', 'openReceipt'],
   disabled: false,
   isLocked: false,
   lastDisabledStatus: false,
@@ -67,7 +67,7 @@
     this.isLocked = false;
     this.setDisabledIfSynchronized();
   },
-  setButtonDisabled: function (value) {
+  setDisabled: function (value) {
     this.lastDisabledStatus = value;
     this.setDisabledIfSynchronized();
   },
@@ -80,13 +80,13 @@
       return true;
     }
     this.disabled = value;
-    this.setDisabled(value);
+    this.setAttribute('disabled', value);
   },
   disabledButton: function (inSender, inEvent) {
     this.updateDisabled(inEvent.disableButtonNew || inEvent.status);
   },
   updateDisabled: function (isDisabled) {
-    this.setButtonDisabled(isDisabled);
+    this.setDisabled(isDisabled);
     if (isDisabled) {
       this.removeClass('btn-icon-new');
     } else {
@@ -140,7 +140,7 @@
   handlers: {
     onLeftToolbarDisabled: 'disabledButton'
   },
-  processesToListen: ['calculateReceipt', 'addProduct', 'completeQuotation'],
+  processesToListen: ['calculateReceipt', 'addProduct', 'completeQuotation', 'openReceipt'],
   disabled: false,
   isLocked: false,
   lastDisabledStatus: false,
diff --git a/web/org.openbravo.retail.posterminal/js/utils/orderSelectorUtils.js b/web/org.openbravo.retail.posterminal/js/utils/orderSelectorUtils.js
--- a/web/org.openbravo.retail.posterminal/js/utils/orderSelectorUtils.js
+++ b/web/org.openbravo.retail.posterminal/js/utils/orderSelectorUtils.js
@@ -31,7 +31,7 @@
 
   OB.UTIL.OrderSelectorUtils.checkOrderAndLoad = function (model, orderList, context, originServer, calledFrom) {
     var me = this,
-        continueAfterPaidReceipt, checkListCallback, errorCallback, orderLoaded, loadOrder, loadOrders, loadOrdersProcess, recursiveCallback, recursiveIdx, currentModel, currentOrderList, currentContext, currentOriginServer, currentCalledFrom;
+        execution, continueAfterPaidReceipt, checkListCallback, errorCallback, orderLoaded, loadOrder, loadOrders, loadOrdersProcess, recursiveCallback, recursiveIdx, currentModel, currentOrderList, currentContext, currentOriginServer, currentCalledFrom;
 
     checkListCallback = function () {
       if (me.listOfReceipts && me.listOfReceipts.length > 0) {
@@ -39,6 +39,7 @@
         loadOrdersProcess(currentReceipt.model, currentReceipt.orderList, currentReceipt.context, currentReceipt.originServer, currentReceipt.calledFrom);
       } else {
         me.loadingReceipt = false;
+        OB.UTIL.ProcessController.finish('openReceipt', execution);
       }
     };
 
@@ -236,6 +237,7 @@
       return;
     }
     me.loadingReceipt = true;
+    execution = OB.UTIL.ProcessController.start('openReceipt');
     if (calledFrom === 'return') {
       currentModel = model;
       currentOrderList = orderList;
