Commit 0cf62a74 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Fix ProductionOrder_viewMaterialConsumption and display materials even when not in the inventory.

parent f0ac3f85
......@@ -50,44 +50,66 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""Returns list of resources\' inventories used in consumption for production\n
<value> <string>"""Returns list of resources\' inventories used in consumption for production\n
\n
Args:\n
- omit_order_resources [default: 1]\n
Do not show resources, which are on order lines.\n
"""\n
if omit_order_resources:\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ZSQLCatalog.SQLCatalog import NegatedQuery\n
\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ZSQLCatalog.SQLCatalog import NegatedQuery\n
ignored_resource_uid_list = [q.getResourceUid() for q in context.getMovementList() if q.getResourceUid() is not None]\n
kwargs[\'query\'] = NegatedQuery(Query(operator=\'IN\',**{\'stock.resource_uid\': ignored_resource_uid_list}))\n
\n
simulation_tool = context.getPortalObject().portal_simulation\n
kw = {}\n
kwargs[\'group_by_date\'] = 1\n
kwargs[\'group_by_node\'] = 1\n
kwargs[\'group_by_variation\'] = 1\n
kwargs[\'group_by_resource\'] = 1\n
kwargs[\'section_uid\'] = context.getDestinationSectionUid()\n
\n
if omit_order_resources:\n
ignored_resource_uid_list = [q.getResourceUid() for q in context.getMovementList() \\\n
if q.getResourceUid() is not None]\n
inventory_dict = {}\n
for inventory in context.portal_simulation.getFutureInventoryList(*args,**kwargs):\n
inventory_dict[inventory.getResourceUid(), \\\n
tuple(sorted(inventory.getVariationCategoryList())), \\\n
inventory.getDestination()] = inventory\n
\n
result_list = inventory_dict.values()\n
consumption_dict = {}\n
for movement in context.getMovementList():\n
movement_quantity_unit = movement.getQuantityUnit()\n
movement_quantity = movement.getQuantity()\n
movement_destination = movement.getDestination()\n
\n
for material in movement.getSpecialiseValue().objectValues():\n
material_resource_uid = material.getResourceUid()\n
if not material_resource_uid:\n
continue\n
\n
inventory_dict_key = material_resource_uid, \\\n
tuple(sorted(material.getVariationCategoryList())), \\\n
movement_destination\n
\n
try:\n
obj = inventory_dict[inventory_dict_key]\n
except KeyError:\n
obj = material\n
result_list.append(obj)\n
\n
kw[\'query\'] = NegatedQuery(\n
Query(operator=\'IN\',**{\'stock.resource_uid\':ignored_resource_uid_list})\n
)\n
material_quantity_unit = material.getQuantityUnit()\n
if movement_quantity_unit == material_quantity_unit:\n
quantity = material.getQuantity()\n
else:\n
quantity = material.getResourceValue().convertQuantity(material.getQuantity(),\n
material_quantity_unit,\n
movement_quantity_unit)\n
\n
kw[\'explanation_uid\'] = [context.getUid()] + [q.getUid() for q in \\\n
context.getCausalityRelatedValueList(portal_type=context.getPortalDeliveryTypeList())]\n
consumption_dict[obj.getUid()] = quantity * movement_quantity\n
\n
kw[\'group_by_date\'] = 1\n
kw[\'group_by_node\'] = 1\n
kw[\'group_by_variation\'] = 1\n
kw[\'group_by_resource\'] = 1\n
kwargs.update(**kw)\n
if kwargs.get(\'src__\',0) == 1:\n
return simulation_tool.getFutureInventoryList(*args,**kwargs)\n
# XXX: below filtering to be replaced by HAVING expression\n
return [q for q in simulation_tool.getFutureInventoryList(*args,**kwargs) if q.inventory < 0.0]\n
]]></string> </value>
context.REQUEST.set(\'consumption_dict\', consumption_dict)\n
return result_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
......@@ -91,7 +91,9 @@
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_movement_start_date</string>
<string>listbox_quantity_unit_item</string>
<string>listbox_consumption_item</string>
<string>listbox_variation_category_item_list</string>
</list>
</value>
</item>
......
......@@ -10,12 +10,12 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>columns</string>
<string>list_method</string>
<string>selection_name</string>
<string>editable_columns</string>
<string>list_action</string>
<string>list_method</string>
<string>selection_name</string>
<string>title</string>
</list>
</value>
</item>
......@@ -85,7 +85,7 @@
<string>Resource</string>
</tuple>
<tuple>
<string>variation_title</string>
<string>variation_category_item_list</string>
<string>Variation</string>
</tuple>
<tuple>
......@@ -93,15 +93,11 @@
<string>Node</string>
</tuple>
<tuple>
<string>movement.start_date</string>
<string>Date</string>
</tuple>
<tuple>
<string>inventory</string>
<string>Quantity</string>
<string>consumption_item</string>
<string>Consumption</string>
</tuple>
<tuple>
<string>quantity_unit</string>
<string>quantity_unit_item</string>
<string>Unit</string>
</tuple>
<tuple>
......@@ -168,10 +164,7 @@
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="Method" module="Products.Formulator.MethodField"/>
<tuple/>
</tuple>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
......
<?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>default</string>
<string>input_style</string>
<string>precision</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_consumption_item</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>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>input_style</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>input_style</string> </key>
<value> <string>-1234.5</string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_consumption_item</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.REQUEST.get(\'consumption_dict\').get(cell.getUid(), \'\')</string> </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>default</string>
<string>display_width</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_quantity_unit_item</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>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>display_width</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>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</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>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_quantity_unit_item</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.getQuantityUnitValue().getTranslatedTitle()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,14 +9,12 @@
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_movement_start_date</string> </value>
<value> <string>listbox_variation_category_item_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -71,17 +69,13 @@
<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_start_date</string> </value>
<value> <string>my_report_mode_listbox_variation_category_item_list</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>ProductionOrderLine_viewFieldLibrary</string> </value>
<value> <string>Base_viewTradeFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
......
2011-06-01 arnaud.fontaine
* Fix ProductionOrder_viewMaterialConsumption and display materials even when not in the inventory.
2011-05-23 tatuya
* Fix the issue that the Stock view on Production Order does not show anything.
......
459
\ No newline at end of file
460
\ 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