details:   https://code.openbravo.com/erp/devel/pi/rev/23f36f89bcf2
changeset: 19636:23f36f89bcf2
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Feb 11 16:49:32 2013 +0100
summary:   Fixes issue 22625: Fixes autosave in grid for new records

The problem was that the new and proper record id (which is not available until 
the row has been saved in the database) was already available when the context 
info was retrieved, but was being overwritten by the old dummy in this line 
[1]. This happened because the old id was not being cleared, due to the fact 
that smartclient does not clear the values of the primary keys [2].

This is fixed by replacing the dummy id with the proper one if:
- The id returned by viewGrid.getEditValues (old one) begins with '_' (is dummy)
- The id returned by viewGrid.getRecord (new one) does not begin with '_' (is 
not dummy)

[1] 
https://code.openbravo.com/erp/devel/pi/file/fe46ee66e77a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js#l1993
[2] 
https://code.openbravo.com/erp/mods/org.openbravo.userinterface.smartclient.dev/file/8c2bc26694da/web/org.openbravo.userinterface.smartclient/isomorphic/client/widgets/ListGrid.js#l28859

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 |  5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diffs (15 lines):

diff -r 0556ae26724d -r 23f36f89bcf2 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Feb 11 16:34:40 2013 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Feb 11 16:49:32 2013 +0100
@@ -1992,6 +1992,11 @@
         } else {
           record = isc.addProperties({}, this.viewGrid.getRecord(rowNum), 
this.viewGrid.getEditValues(rowNum));
         }
+        // Prevents the proper id from being overwritten with the dummy id
+        // See issue https://issues.openbravo.com/view.php?id=22625
+        if (this.viewGrid.getEditValues(rowNum)[OB.Constants.ID].indexOf('_') 
=== 0 && this.viewGrid.getRecord(rowNum)[OB.Constants.ID].indexOf('_') !== 0) {
+          record[OB.Constants.ID] = 
this.viewGrid.getRecord(rowNum)[OB.Constants.ID];
+        }
       } else {
         record = isc.addProperties({}, this.viewGrid.getSelectedRecord());
       }

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to