Fixed issue 25125:Creating a new Sales Order sets Organization as disabled
authorGuillermo Gil <guillermo.gil@openbravo.com>
Mon, 14 Apr 2014 09:28:56 +0200
changeset 22910 c41ba68ffe38
parent 22909 2bd8c0fe3cbb
child 22911 d80d8cd8e39b
Fixed issue 25125:Creating a new Sales Order sets Organization as disabled

Moved var Id and compared to form value once autoSave is Done, if it is different set isNew as true because the record has changed.
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	Wed Apr 09 22:38:31 2014 +0530
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Mon Apr 14 09:28:56 2014 +0200
@@ -1536,7 +1536,7 @@
     callback = function (resp, data, req) {
       var index1, index2, view = form.view,
           localRecord, status = resp.status,
-          sessionProperties, keepSelection, gridRefreshCallback, theGrid, theId;
+          sessionProperties, keepSelection, gridRefreshCallback, theGrid, theId, id = form.getValue('id');
 
       if (this.hasOwnProperty('previousExplicitOffline')) {
         isc.Offline.explicitOffline = this.previousExplicitOffline;
@@ -1545,7 +1545,6 @@
 
       // if no recordIndex then select explicitly
       if (recordIndex === -1) {
-        var id = form.getValue('id');
         record = view.viewGrid.data.find('id', id);
         recordIndex = view.viewGrid.data.indexOf(record);
       }
@@ -1632,8 +1631,15 @@
         // remove any edit info in the grid
         view.viewGrid.discardEdits(recordIndex, null, false, isc.ListGrid.PROGRAMMATIC, true);
 
-        // change some labels
-        form.setNewState(false);
+        // Check if Id has changed 
+        if (id === form.getValue('id')) {
+          // Change some labels, set isNew as false
+          form.setNewState(false);
+        } else {
+          // New record, set isNew as true
+          form.setNewState(true);
+        }
+
 
         view.refreshParentRecord();