From a1818daa2c1cbb509f9d7693ce1dd8d35bf4c5ef Mon Sep 17 00:00:00 2001
From: Tatuya Kamada <tatuya@nexedi.com>
Date: Tue, 30 Aug 2011 18:56:40 +0900
Subject: [PATCH] Fix the issue that the Stock tab in Production Order or
 Production Packing List returns all the inventories when the Deliveries do
 not have a resource.

---
 .../ProductionDelivery_getFutureInventoryList.xml    | 12 ++++++++++++
 bt5/erp5_mrp/bt/change_log                           |  3 +++
 bt5/erp5_mrp/bt/revision                             |  2 +-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionDelivery_getFutureInventoryList.xml b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionDelivery_getFutureInventoryList.xml
index 883ceb20ff..7ab69591d2 100644
--- a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionDelivery_getFutureInventoryList.xml
+++ b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionDelivery_getFutureInventoryList.xml
@@ -52,6 +52,18 @@
             <key> <string>_body</string> </key>
             <value> <string>"""List Method script to show only inventory for destination"""\n
 \n
+# When the delivery does not have a resource, returns empty list.\n
+# Otherwise it returns all the inventories in your ERP5 site.\n
+production_delivery = context\n
+movement_list = production_delivery.getMovementList()\n
+empty = True\n
+for movement in movement_list:\n
+  if movement.getResource() not in (None, \'\'):\n
+    empty = False\n
+    break           \n
+if empty:\n
+  return []\n
+\n
 portal_type_dict_mapping = {\n
   \'Production Order\' : {\'node_uid\' : context.getDestinationUid()},\n
 }\n
diff --git a/bt5/erp5_mrp/bt/change_log b/bt5/erp5_mrp/bt/change_log
index 6768c7d021..be45d457f8 100644
--- a/bt5/erp5_mrp/bt/change_log
+++ b/bt5/erp5_mrp/bt/change_log
@@ -1,3 +1,6 @@
+2011-08-30 tatuya
+* Fix the issue that the Stock tab in Production Order or Production Packing List returns all the inventories when the Deliveries do not have a resource.
+
 2011-08-30 tatuya
 * Fix to show quantity unit title in the listbox of the Stock tab.
 
diff --git a/bt5/erp5_mrp/bt/revision b/bt5/erp5_mrp/bt/revision
index 281cd66131..4af7c92223 100644
--- a/bt5/erp5_mrp/bt/revision
+++ b/bt5/erp5_mrp/bt/revision
@@ -1 +1 @@
-469
\ No newline at end of file
+470
\ No newline at end of file
-- 
2.30.9