# HG changeset patch
# User Asier Lostalé <asier.lostale@openbravo.com>
# Date 1476367157 -7200
#      Thu Oct 13 15:59:17 2016 +0200
# Node ID 69400c6e986bdcc84368f635553c8f8fe7fbdd5b
# Parent  0d765967dc06ab45395b44e4d74df469c6de3b8b
fixed bug 34200: client side callouts executed twice

  When picking a value from a selector drop down, its associated client side
  callouts were executed twice.

  The problem was caused because in this situation fullIdentifierEntered flag
  was set to true and it causes the field blur event to trigger again the callouts.

  It has been prevented by adding a new valuePicked flag which is set to true
  when a value is picked from drop down, in this case fullIdentifierEntered is
  not set to true.

diff -r 0d765967dc06 -r 69400c6e986b 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	Thu Oct 13 09:28:06 2016 +0000
+++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Thu Oct 13 15:59:17 2016 +0200
@@ -672,7 +672,7 @@
 
     // check if the whole item identifier has been entered
     // see issue https://issues.openbravo.com/view.php?id=22821
-    if (OB.Utilities.isUUID(this.mapDisplayToValue(identifier)) && this._notUpdatingManually !== true) {
+    if (OB.Utilities.isUUID(this.mapDisplayToValue(identifier)) && this._notUpdatingManually !== true && !this.valuePicked) {
       this.fullIdentifierEntered = true;
     } else {
       delete this.fullIdentifierEntered;
@@ -1004,10 +1004,13 @@
   },
 
   pickValue: function (value) {
+    var selectedRecord, ret;
     // get the selected record before calling the super, as this super call
     // will deselect the record
-    var selectedRecord = this.pickList.getSelectedRecord(),
-        ret = this.Super('pickValue', arguments);
+    selectedRecord = this.pickList.getSelectedRecord();
+    this.valuePicked = true;
+    ret = this.Super('pickValue', arguments);
+    delete this.valuePicked;
     this.setValueFromRecord(selectedRecord);
     delete this.fullIdentifierEntered;
     return ret;
