verify some state info before editing PO
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Jun 2008 03:16:36 +0000 (03:16 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Jun 2008 03:16:36 +0000 (03:16 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9913 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/po/li_search.js

index 20238aa..f8bcbdd 100644 (file)
@@ -88,11 +88,14 @@ function createPOFromLineitems() {
         var rowIdx = selected[idx];
         var id = liGrid.model.getRow(rowIdx).id;
         for(var i = 0; i < lineitems.length; i++) {
-            if(lineitems[i].id() == id)
+            var li = lineitems[i];
+            if(li.id() == id && !li.purchase_order() && li.state == 'approved')
                 selList.push(lineitems[i]);
         }
     }
 
+    if(selList.length == 0) return;
+
     openils.acq.PO.create(po, 
         function(poId) {
             updateLiList(poId, selList);
@@ -108,8 +111,6 @@ function _updateLiList(poId, selList, idx) {
     if(idx >= selList.length)
         return location.href = 'view/' + poId;
     var li = selList[idx];
-    if(li.purchase_order())
-        return _updateLiList(poId, selList, ++idx);
     li.purchase_order(poId);
     new openils.acq.Lineitems({lineitem:li}).update(
         function(stat) {