details:   https://code.openbravo.com/erp/devel/pi/rev/f8951754dc84
changeset: 28182:f8951754dc84
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Mon Jan 11 19:22:20 2016 +0100
summary:   fixes issue 31331: When add new lines in sales order the product 
appears filled

Two different flows were resulting in this problem. From one side, if we 
clicked directly on the new record button quickly after filling the combo value 
it could happen that the new form was created before the filter operation of 
the combo finished. To overcome this problem now a temporary id is generated 
every time we edit/create a new record in form. This id is checked once the 
combo filter operation ends, to identify if the form has changed. In that case, 
the flow to be executed after the filter operations is cancelled.

>From other side, the same proble could happen if we clicked on the new record 
>button quickly after clicking on the save record button. In this case, it 
>could happen that after clearing the values a wrong entry was retrieved for 
>the combo using the mapValueToDisplay() function. To solve this problem, now 
>in the setEntries() function we include the value field information. This 
>helps to retrieve the correct value on the described circumnstances.

Together with this, a new utility function has been created in order to have a 
common function to generate 'temporary' ids.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-combo.js
 |  19 +++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
               |   4 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
           |   5 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
          |   9 +++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-view-manager.js
       |   2 +-
 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
        |  23 +++++++--
 6 files changed, 49 insertions(+), 13 deletions(-)

diffs (172 lines):

diff -r 1817418c55af -r f8951754dc84 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-combo.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-combo.js
       Tue Dec 29 11:32:34 2015 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-combo.js
       Mon Jan 11 19:22:20 2016 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2015 Openbravo SLU
+ * All portions are Copyright (C) 2015-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,9 +28,12 @@
   // Prevents validation of this item while filtering because real value is 
not 
   // set yet.
   // see issues #26189 and #28651
-  filterComplete: function () {
+  filterComplete: function (response, data, request, fromSharedPickList) {
     var ret;
 
+    if (request && request.params && request.params.recordIdInForm && 
request.params.recordIdInForm !== this.form.recordIdInForm) {
+      return;
+    }
     this.preventValidation = true;
     ret = this.Super('filterComplete', arguments);
     delete this.preventValidation;
@@ -62,5 +65,17 @@
       }
     }
     return false;
+  },
+
+  // This function will fall through to filterComplete() when the filter 
operation returns
+  filterDataBoundPickList: function (requestProperties, dropCache) {
+    if (this.form && this.form.view && this.form.view.isShowingForm) {
+      // Identify the record being currently edited in form view and include 
it in the request.
+      // It will be used to avoid problems when a new record is opened in form 
view before filterComplete() finishes
+      // See issue https://issues.openbravo.com/view.php?id=31331
+      requestProperties.params = requestProperties.params || {};
+      requestProperties.params.recordIdInForm = this.form.recordIdInForm;
+    }
+    return this.Super('filterDataBoundPickList', [requestProperties, 
dropCache]);
   }
 });
\ No newline at end of file
diff -r 1817418c55af -r f8951754dc84 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Tue Dec 29 11:32:34 2015 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Mon Jan 11 19:22:20 2016 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2015 Openbravo SLU
+ * All portions are Copyright (C) 2010-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -2986,7 +2986,7 @@
     // it MUST start with _ to identify it is a temporary id 
     var record = {
       _new: true,
-      id: '_' + new Date().getTime()
+      id: OB.Utilities.getTemporaryId()
     };
 
     this.addToCacheData(record, rowNum);
diff -r 1817418c55af -r f8951754dc84 
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
 Tue Dec 29 11:32:34 2015 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Jan 11 19:22:20 2016 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2015 Openbravo SLU
+ * All portions are Copyright (C) 2010-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -1476,6 +1476,9 @@
     // at this point the time fields of the record are formatted in local time
     localTime = true;
     this.messageBar.hide();
+    // Set a temporary identifier for the record being edited in form view
+    // See issue https://issues.openbravo.com/view.php?id=31331
+    this.viewForm.recordIdInForm = OB.Utilities.getTemporaryId();
 
     if (!this.isShowingForm) {
       this.switchFormGridVisibility();
diff -r 1817418c55af -r f8951754dc84 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
        Tue Dec 29 11:32:34 2015 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
        Mon Jan 11 19:22:20 2016 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2015 Openbravo SLU
+ * All portions are Copyright (C) 2011-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -1310,4 +1310,11 @@
   grid.dataProperties.manualResultSet = true;
   grid.setData(grid.createDataModel());
   grid.serverDataNotLoaded = true;
+};
+
+//** {{{ OB.Utilities.getTemporaryId }}} **
+//
+// Returns a temporary id that starts with _
+OB.Utilities.getTemporaryId = function () {
+  return '_' + new Date().getTime();
 };
\ No newline at end of file
diff -r 1817418c55af -r f8951754dc84 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-view-manager.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-view-manager.js
     Tue Dec 29 11:32:34 2015 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-view-manager.js
     Mon Jan 11 19:22:20 2016 +0100
@@ -118,7 +118,7 @@
       var layout = OB.Utilities.createLoadingLayout();
       // is used to prevent history updating
       layout.isLoadingTab = true;
-      viewTabId = viewTabId || params.currentViewTabId || '_' + new 
Date().getTime();
+      viewTabId = viewTabId || params.currentViewTabId || 
OB.Utilities.getTemporaryId();
       params.loadingTabId = viewTabId;
       this.createTab(viewId, viewTabId, layout, params);
       return params;
diff -r 1817418c55af -r f8951754dc84 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
--- 
a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Tue Dec 29 11:32:34 2015 +0100
+++ 
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Mon Jan 11 19:22:20 2016 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2015 Openbravo SLU
+ * All portions are Copyright (C) 2011-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -518,7 +518,8 @@
   setEntries: function (entries) {
     var length = entries.length,
         i, id, identifier, valueMap = {},
-        valueMapData = [];
+        valueMapElement, valueField = this.getValueFieldName(),
+        valueFieldContent, valueMapData = [];
 
     if (!this.setValueMap) {
       return;
@@ -529,10 +530,20 @@
       identifier = entries[i][OB.Constants.IDENTIFIER] || '';
       valueMap[id] = identifier;
 
-      valueMapData.push({
-        _identifier: identifier,
-        id: id
-      });
+      valueMapElement = {};
+      valueMapElement[OB.Constants.IDENTIFIER] = identifier;
+      valueMapElement[OB.Constants.ID] = id;
+
+      // We include the value field into the entry.
+      // With this we avoid to retrieve an incorrect value from 
mapValueToDisplay() when looking for undefined values.
+      // This could happen when creating a new record in form view, after 
clearing the values.
+      // See issue https://issues.openbravo.com/view.php?id=31331
+      if (valueField) {
+        valueFieldContent = entries[i][valueField] || '';
+        valueMapElement[valueField] = valueFieldContent;
+      }
+
+      valueMapData.push(valueMapElement);
     }
 
     this.wholeMapSet = true; // flag to use local filtering from now on

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to