Commit 34ee2d50 authored by Mame Coumba Sall's avatar Mame Coumba Sall

2008-12-17 mame

* Modify script to not display stock of the resource when it's positive, negative or equal to zero

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24919 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24793288
...@@ -62,13 +62,13 @@ def mycmp(line_a, line_b):\n ...@@ -62,13 +62,13 @@ def mycmp(line_a, line_b):\n
Compare 2 lines and sort them according to\n Compare 2 lines and sort them according to\n
sort_on parameter.\n sort_on parameter.\n
"""\n """\n
\n
result = cmp(line_a.getResourceReference(), line_b.getResourceReference())\n result = cmp(line_a.getResourceReference(), line_b.getResourceReference())\n
if result == 0:\n if result == 0:\n
result = cmp(line_a.variation_text, line_b.variation_text)\n result = cmp(line_a.variation_text, line_b.variation_text)\n
if result == 0:\n if result == 0:\n
result = cmp(line_a.resource_title, line_b.resource_title)\n result = cmp(line_a.resource_title, line_b.resource_title)\n
return result\n return result\n
\n
result_list = []\n result_list = []\n
for x in context.portal_simulation.getCurrentInventoryList(\n for x in context.portal_simulation.getCurrentInventoryList(\n
stock_node_category_uid=site.getUid(),\n stock_node_category_uid=site.getUid(),\n
...@@ -79,12 +79,14 @@ for x in context.portal_simulation.getCurrentInventoryList(\n ...@@ -79,12 +79,14 @@ for x in context.portal_simulation.getCurrentInventoryList(\n
# XXX resourceType= uses movement table.\n # XXX resourceType= uses movement table.\n
# resource_portal_type= does not work with cells (because resource is acquired from line)\n # resource_portal_type= does not work with cells (because resource is acquired from line)\n
resourceType=context.getPortalProductTypeList(), **kw):\n resourceType=context.getPortalProductTypeList(), **kw):\n
if positive_stock and x.getInventory() > 0:\n if x.inventory <=0 and positive_stock:\n
result_list.append(x)\n result_list.append(x)\n
if negative_stock and x.getInventory() < 0:\n if x.inventory>=0 and negative_stock:\n
result_list.append(x)\n result_list.append(x)\n
if zero_stock and x.getInventory()==0:\n if x.inventory!=0 and zero_stock:\n
result_list.append(x)\n result_list.append(x) \n
if not positive_stock and not negative_stock and not zero_stock:\n
result_list.append(x)\n
\n \n
result_list = list(result_list)\n result_list = list(result_list)\n
result_list.sort(cmp=mycmp)\n result_list.sort(cmp=mycmp)\n
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<value> <value>
<list> <list>
<string>title</string> <string>title</string>
<string>description</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -74,6 +75,10 @@ ...@@ -74,6 +75,10 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>Don\'t display the negative stock of the resource if stock is negative</string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_checkbox</string> </value> <value> <string>my_checkbox</string> </value>
...@@ -88,7 +93,7 @@ ...@@ -88,7 +93,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Negative Stock</string> </value> <value> <string>Don\'t Display Negative Stock</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<value> <value>
<list> <list>
<string>title</string> <string>title</string>
<string>description</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -74,6 +75,10 @@ ...@@ -74,6 +75,10 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>Don\'t display positive stock of the resource if stock is positive</string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_checkbox</string> </value> <value> <string>my_checkbox</string> </value>
...@@ -88,7 +93,7 @@ ...@@ -88,7 +93,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Positive Stock</string> </value> <value> <string>Don\'t Display Positive Stock</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<value> <value>
<list> <list>
<string>title</string> <string>title</string>
<string>description</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -74,6 +75,10 @@ ...@@ -74,6 +75,10 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>Don\'t display zero stock of the resource if stock is equal to zero</string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_checkbox</string> </value> <value> <string>my_checkbox</string> </value>
...@@ -88,7 +93,7 @@ ...@@ -88,7 +93,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Zero Stock</string> </value> <value> <string>Don\'t Display Zero Stock</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
......
550 551
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment