Fixes issue 21657: It is possible to save views that have ids in its fields
authorAugusto Mauch <augusto.mauch@openbravo.com>
Mon, 17 Sep 2012 10:22:29 +0200
changeset 17963 35a4bff5296e
parent 17962 ce2509bd136d
child 17964 a4446328523a
Fixes issue 21657: It is possible to save views that have ids in its fields

If a window that an id in its fields, it was not possible to save new records because the ID was a mandatory field without value, so the save button was not enabled. Now the allRequiredFieldsSet function has been modified, so it does not take into account id fields, because its value will be set in dal before inserting the new row in the database.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Fri Sep 14 12:45:05 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Mon Sep 17 10:22:29 2012 +0200
@@ -1886,13 +1886,19 @@
     }
   },
 
+  isID: function (item) {
+    return item.type === '_id_13';
+  },
+
   allRequiredFieldsSet: function () {
     var i, item, length = this.getItems().length,
         value, undef, nullValue = null;
     for (i = 0; i < length; i++) {
       item = this.getItems()[i];
       value = item.getValue();
-      if (this.isRequired(item) && value !== false && value !== 0 && !value) {
+      // Do no check ids, even though they are mandatory they are automatically set DAL before
+      // storing the record in the database. See issue https://issues.openbravo.com/view.php?id=21657
+      if (this.isRequired(item) && !this.isID(item) && value !== false && value !== 0 && !value) {
         return false;
       }
     }