Commit ce99e803 authored by Jérome Perrin's avatar Jérome Perrin

pdm: repair converted inventory report listbox

getConvertedInventoryList is deprectated and use mergeResults which
does not support brain classes, so the brain.node_title was no longer
correct.
Use a simpler approach, same as Resource_getInventoryList ("stock
browser"), ie: getFutureInventoryList to get all future stocks +
getCurrentInventory and getAvailableInventory for each brain. It's a bit
less efficient because we now do 2 getInventory for each line instead of
3 getInventoryList merged, but that should be enough.

Also:
 - use float fields to format numbers properly
 - activate domain tree for site (instead of showing all nodes)
parent bca53113
kw['resource_uid'] = context.ResourceModule_getSelection().getUidList()
from Products.PythonScripts.standard import Object
portal = context.getPortalObject()
if kw.setdefault('inventory_list', 1):
kw.update(group_by_node = 1, group_by_resource = 0)
else:
kw.update(ignore_group_by = 1)
resource_uid = context.ResourceModule_getSelection().getUidList()
kw.update(group_by_node=1, group_by_resource=0, resource_uid=resource_uid)
return context.getPortalObject().portal_simulation \
.getConvertedInventoryList(simulation_period='All', **kw)
def makeResultLine(brain):
def getCurrentInventory():
return portal.portal_simulation.getCurrentInventory(
node_uid=brain.node_uid,
resource_uid=resource_uid,
quantity_unit=kw['quantity_unit'],
metric_type=kw['metric_type'],
)
def getAvailableInventory():
return portal.portal_simulation.getAvailableInventory(
node_uid=brain.node_uid,
resource_uid=resource_uid,
quantity_unit=kw['quantity_unit'],
metric_type=kw['metric_type'],
)
return Object(
uid='new_',
node_title=brain.node_title,
converted_quantity=brain.converted_quantity,
getCurrentInventory=getCurrentInventory,
getAvailableInventory=getAvailableInventory,
)
result_list = []
for brain in portal.portal_simulation.getFutureInventoryList(**kw):
result_list.append(makeResultLine(brain))
return result_list
return context.ResourceModule_getConvertedInventoryList(inventory_list=0, **kw)
from Products.PythonScripts.standard import Object
portal = context.getPortalObject()
resource_uid = context.ResourceModule_getSelection().getUidList()
obj = Object(uid="new_")
obj["node_title"] = ""
obj["section_title"] = ""
obj["variation_text"] = ""
obj["getCurrentInventory"] = portal.portal_simulation.getCurrentInventory(
quantity_unit=kw['quantity_unit'],
metric_type=kw['metric_type'],
resource_uid=resource_uid,
selection_domain=kw.get('selection_domain', None))
obj["getAvailableInventory"] = portal.portal_simulation.getAvailableInventory(
quantity_unit=kw['quantity_unit'],
resource_uid=resource_uid,
metric_type=kw['metric_type'],
selection_domain=kw.get('selection_domain', None))
obj["converted_quantity"] = portal.portal_simulation.getFutureInventory(
quantity_unit=kw['quantity_unit'],
resource_uid=resource_uid,
metric_type=kw['metric_type'],
selection_domain=kw.get('selection_domain', None))
return [obj,]
......@@ -80,7 +80,11 @@
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
<list>
<string>listbox_getAvailableInventory</string>
<string>listbox_getCurrentInventory</string>
<string>listbox_converted_quantity</string>
</list>
</value>
</item>
<item>
......
......@@ -10,13 +10,14 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>columns</string>
<string>domain_root_list</string>
<string>domain_tree</string>
<string>editable</string>
<string>enabled</string>
<string>list_method</string>
<string>stat_method</string>
<string>stat_columns</string>
<string>enabled</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
......@@ -118,20 +119,35 @@
<string>Site or Warehouse</string>
</tuple>
<tuple>
<string>current_converted_quantity</string>
<string>getCurrentInventory</string>
<string>Current</string>
</tuple>
<tuple>
<string>available_converted_quantity</string>
<string>getAvailableInventory</string>
<string>Available</string>
</tuple>
<tuple>
<string>future_converted_quantity</string>
<string>converted_quantity</string>
<string>Future</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>domain_root_list</string> </key>
<value>
<list>
<tuple>
<string>site</string>
<string>Site</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>domain_tree</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
......@@ -154,25 +170,6 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>stat_columns</string> </key>
<value>
<list>
<tuple>
<string>current_converted_quantity</string>
<string>current_converted_quantity</string>
</tuple>
<tuple>
<string>available_converted_quantity</string>
<string>available_converted_quantity</string>
</tuple>
<tuple>
<string>future_converted_quantity</string>
<string>future_converted_quantity</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>stat_method</string> </key>
<value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_converted_quantity</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_getAvailableInventory</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_getCurrentInventory</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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