Index: trunk/grails-app/i18n/messages.properties
===================================================================
--- trunk/grails-app/i18n/messages.properties	(revision 546)
+++ trunk/grails-app/i18n/messages.properties	(revision 547)
@@ -315,4 +315,5 @@
 
 # Reports
+report.too.many.results.warning=Warning over {0} results, please run report again.
 report.stock.take.overview=Stock Take (Overview)
 report.stock.take.overview.help=Use this report to manage inventory stock take. Use in conjunction with the Stock Take (By Location) report.
Index: trunk/grails-app/services/InventoryReportService.groovy
===================================================================
--- trunk/grails-app/services/InventoryReportService.groovy	(revision 546)
+++ trunk/grails-app/services/InventoryReportService.groovy	(revision 547)
@@ -13,5 +13,5 @@
     def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib()
 
-//     def paramsMax = 100000
+    def paramsMax = 250
 
     /**
@@ -61,4 +61,7 @@
         result.locations = result.locations.collect {it.trim()}
 
+        def paginateParams = [:]
+        paginateParams.max = Math.min(params?.max?.toInteger() ?: paramsMax, paramsMax)
+
         def namedParams = [:]
         namedParams.locationList = [null] // null protects against HQL unexpected end of subtree exception with an empty list.
@@ -71,4 +74,37 @@
         }
 
+        // Return the actual locations as a string.
+        if(namedParams.locationList.size() > 1)
+            result.locations = namedParams.locationList[1..-1].toString()[1..-2]
+        else
+            result.locations = g.message(code: 'default.none.text')
+
+        // Inventory List.
+        result.inventoryListQuery = "from InventoryItem as inventoryItem \
+                                                        left join inventoryItem.inventoryLocation as inventoryLocation \
+                                                        where (inventoryItem.isActive = true \
+                                                                    and  inventoryItem.inventoryLocation in (:locationList) \
+                                                                    ) "
+
+        result.inventoryCountQuery = "select count(distinct inventoryItem) " + result.inventoryListQuery
+        result.inventoryItemCount = InventoryItem.executeQuery(result.inventoryCountQuery, namedParams)[0]
+
+        // Exit if too many results.
+        result.countWarning = null
+        if(result.inventoryItemCount > paramsMax) {
+            result.countWarning = g.message(code: 'report.too.many.results.warning',
+                                                                    args: [paramsMax],
+                                                                    default: "Warning over ${paramsMax} results, please run report again!")
+            result.inventoryItemList = []
+            return result
+        }
+
+        result.inventoryListQuery = "select distinct inventoryItem " + result.inventoryListQuery
+        def inventoryList = InventoryItem.executeQuery(result.inventoryListQuery, namedParams, paginateParams)
+
+        // Reset namedParams for next query.
+        namedParams = [:]
+        namedParams.inventoryList = inventoryList
+
         // Note: HQL docs advise not using fetch aliases in where clause (or any other clause).
         // Access is via the parent object, however that does not work for the order by clause in this case.
@@ -79,20 +115,10 @@
                                         left join fetch inventoryItem.picture as picture \
                                         left join fetch picture.images as Image \
-                                        where (inventoryItem.isActive = true \
-                                                    and  inventoryItem.inventoryLocation in (:locationList) \
+                                        where (inventoryItem in (:inventoryList) \
                                                     ) \
                                         order by inventoryStore.name, inventoryLocation.name"
 
-        result.query = "select distinct inventoryItem " + result.query
-        result.queryResult = InventoryLocation.executeQuery(result.query, namedParams)
-        result.inventoryItemCount = result.queryResult.size()
-
-        // Return the actual locations as a string.
-        if(namedParams.locationList.size() > 1)
-            result.locations = namedParams.locationList[1..-1].toString()[1..-2]
-        else
-            result.locations = g.message(code: 'default.none.text')
-
-        result.inventoryItemList = result.queryResult
+        result.query = "select inventoryItem " + result.query
+        result.inventoryItemList = InventoryItem.executeQuery(result.query, namedParams, paginateParams)
 
         // Success.
Index: trunk/grails-app/views/inventoryItemPurchaseDetailed/edit.gsp
===================================================================
--- trunk/grails-app/views/inventoryItemPurchaseDetailed/edit.gsp	(revision 546)
+++ trunk/grails-app/views/inventoryItemPurchaseDetailed/edit.gsp	(revision 547)
@@ -40,8 +40,10 @@
                         
                             <tr class="prop">
-                                <td valign="top" class="name">Purchase Order Number:</td>
-                                
-                                <td valign="top" class="value">${fieldValue(bean:inventoryItemPurchaseInstance, field:'purchaseOrderNumber')}</td>
-                                
+                                <td valign="top" class="name">
+                                    <label for="invoiceNumber">Purchase Order Number:</label>
+                                </td>
+                                <td valign="top" class="value ${hasErrors(bean:inventoryItemPurchaseInstance,field:'purchaseOrderNumber','errors')}">
+                                    <input type="text" maxlength="50" id="purchaseOrderNumber" name="purchaseOrderNumber" value="${fieldValue(bean:inventoryItemPurchaseInstance,field:'purchaseOrderNumber')}"/>
+                                </td>
                             </tr>
                         
@@ -139,4 +141,13 @@
                             </tr>
                         
+                            <tr class="prop">
+                                <td valign="top" class="name">
+                                    <label for="comment">Comment:</label>
+                                </td>
+                                <td valign="top" class="value ${hasErrors(bean:inventoryItemPurchaseInstance,field:'comment','errors')}">
+                                    <textarea rows="5" cols="40" name="comment">${fieldValue(bean:inventoryItemPurchaseInstance, field:'comment')}</textarea>
+                                </td>
+                            </tr>
+                        
                         </tbody>
                     </table>
