commit 125028c425f313faf5d82f8514c7ea34ce2fd1d1
Author: Miguel Alsasua <miguel.alsasua@openbravo.com>
Date:   Mon Nov 8 09:42:35 2021 +0100

    ticket 24073: not allow no cash payments

diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml
index 3743e2a..e3b3ccf 100644
--- a/src-db/database/sourcedata/AD_MESSAGE.xml
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml
@@ -72,4 +72,16 @@
 <!--A95233C3F3AC40D5906ECBF69C5A135D-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--A95233C3F3AC40D5906ECBF69C5A135D--></AD_MESSAGE>
 
+<!--DBA0A7B55E474C4FB45C6F6788C04063--><AD_MESSAGE>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <AD_MESSAGE_ID><![CDATA[DBA0A7B55E474C4FB45C6F6788C04063]]></AD_MESSAGE_ID>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <VALUE><![CDATA[OBRTM_OnlyCashPaymentAllowed]]></VALUE>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <MSGTEXT><![CDATA[You are working in Training Mode. Only Cash payment is allowed]]></MSGTEXT>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <AD_MODULE_ID><![CDATA[266378042BB34872BB658EB9B801E88A]]></AD_MODULE_ID>
+<!--DBA0A7B55E474C4FB45C6F6788C04063-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--DBA0A7B55E474C4FB45C6F6788C04063--></AD_MESSAGE>
+
 </data>
diff --git a/src/org/openbravo/retail/trainingmode/OBRTMComponentProvider.java b/src/org/openbravo/retail/trainingmode/OBRTMComponentProvider.java
index 6c7adba..d4009f9 100644
--- a/src/org/openbravo/retail/trainingmode/OBRTMComponentProvider.java
+++ b/src/org/openbravo/retail/trainingmode/OBRTMComponentProvider.java
@@ -40,7 +40,7 @@ public class OBRTMComponentProvider extends BaseComponentProvider {
     final String assetsPrefix = prefix + "/assets/";
 
     String[] resourceList = { "obrtm-utils", "ordersavehook", "menu", "preprinthook",
-        "predeleteorder", "checkEnoughCashAvailableExtension" };
+        "predeleteorder", "checkEnoughCashAvailableExtension", "prepaymenthook" };
     String[] cssDependency = { "ob-trainingmode" };
 
     for (String resource : resourceList) {
diff --git a/web/org.openbravo.retail.trainingmode/js/prepaymenthook.js b/web/org.openbravo.retail.trainingmode/js/prepaymenthook.js
new file mode 100644
index 0000000..7f69bcb
--- /dev/null
+++ b/web/org.openbravo.retail.trainingmode/js/prepaymenthook.js
@@ -0,0 +1,22 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2021 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+
+OB.UTIL.HookManager.registerHook('OBPOS_preAddPayment', function(
+  args,
+  callbacks
+) {
+  if (OB.OBRTM.isInTrainingMode && !args.paymentToAdd.get('isCash')) {
+    args.cancellation = true;
+    OB.UTIL.showConfirmation.display(
+      OB.I18N.getLabel('OBMOBC_Error'),
+      OB.I18N.getLabel('OBRTM_OnlyCashPaymentAllowed')
+    );
+  }
+  OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+});
