details:   https://code.openbravo.com/erp/devel/pi/rev/268662168c37
changeset: 35920:268662168c37
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Wed May 29 13:56:33 2019 +0200
summary:   fixes bug 40723: Client validation skipped in P&E grids without 
select column

  The client validations done to ensure that mandatory fields in a P&E grid are 
populated before executing a process were not being executed for those grids 
that does not allow selection.

  This is because validations were done just for the selected records of the 
P&E grid.

  Now we validate all the records in case the P&E grid does not allow selection.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-pickeditgrid.js
 |  19 ++++++---
 1 files changed, 12 insertions(+), 7 deletions(-)

diffs (36 lines):

diff -r 1d550d6c5cc6 -r 268662168c37 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-pickeditgrid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-pickeditgrid.js
        Wed May 29 16:11:55 2019 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-pickeditgrid.js
        Wed May 29 13:56:33 2019 +0200
@@ -31,20 +31,25 @@
     condition: function (item) {
       var grid = item.canvas.viewGrid,
           hasErrors = false,
-          i, j, fields, selection, len, record, lineNumbers;
+          i, j, fields, recordsToValidate, record, lineNumbers;
       grid.endEditing();
       fields = grid.getFields();
-      selection = grid.getSelectedRecords() || [];
-      len = selection.length;
-      for (i = 0; i < len; i++) {
-        record = grid.getEditedRecord(grid.getRecordIndex(selection[i]));
+      if (grid.viewProperties && grid.viewProperties.showSelect) {
+        // validate the selected records
+        recordsToValidate = grid.getSelectedRecords() || [];
+      } else {
+        // grid doesn't allow record selection, validate all the records
+        recordsToValidate = (grid.data && grid.data.allRows) || [];
+      }
+      for (i = 0; i < recordsToValidate.length; i++) {
+        record = 
grid.getEditedRecord(grid.getRecordIndex(recordsToValidate[i]));
         for (j = 0; j < fields.length; j++) {
           if (fields[j].required && (record[fields[j].name] === null || 
record[fields[j].name] === undefined || record[fields[j].name] === '')) {
             hasErrors = true;
             if (!lineNumbers) {
-              lineNumbers = grid.getRecordIndex(selection[i]).toString();
+              lineNumbers = 
grid.getRecordIndex(recordsToValidate[i]).toString();
             } else {
-              lineNumbers = lineNumbers + ',' + 
grid.getRecordIndex(selection[i]).toString();
+              lineNumbers = lineNumbers + ',' + 
grid.getRecordIndex(recordsToValidate[i]).toString();
             }
           }
         }


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to