diff --git a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrder_getConsumptionMovementList.xml b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrder_getConsumptionMovementList.xml new file mode 100644 index 0000000000000000000000000000000000000000..3d74ef90ae4491ceb58520f4e12e7033e8a2cc49 --- /dev/null +++ b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrder_getConsumptionMovementList.xml @@ -0,0 +1,139 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_body</string> </key> + <value> <string>"""Returns list of resources\' inventories used in consumption for production\n + Show only resources which are defined in transformation.\n +"""\n +movement_list = context.getMovementList()\n +transformation_line_list_dict = {}\n +consumed_resource_list = []\n +for movement in movement_list:\n + transformation = movement.getSpecialiseValue()\n + if transformation is not None:\n + transformation_line_list = transformation.objectValues()\n + transformation_line_list_dict[movement] = transformation_line_list\n + for transformation_line in transformation_line_list:\n + transformation_resource = transformation_line.getResourceValue()\n + if transformation_resource is not None:\n + consumed_resource_list.append(transformation_resource)\n + else:\n + transformation_line_list_dict[movement] = ()\n +\n +if not consumed_resource_list:\n + return ()\n +\n +kwargs[\'resource_uid\'] = [resource.getUid() for resource in consumed_resource_list]\n +kwargs[\'group_by_section\'] = 0\n +kwargs[\'group_by_node\'] = 1\n +kwargs[\'group_by_variation\'] = 1\n +kwargs[\'section_uid\'] = context.getSourceSectionUid()\n +\n +inventory_dict = {}\n +for inventory in context.portal_simulation.getFutureInventoryList(*args,**kwargs):\n + inventory_dict[inventory.resource_relative_url,\n + inventory.variation_text,\n + inventory.node_relative_url] = inventory\n +\n +result_list = inventory_dict.values()\n +consumption_dict = {}\n +for movement in movement_list:\n + for material in transformation_line_list_dict[movement]:\n + material_resource = material.getResource()\n + if material_resource is None:\n + continue\n +\n + inventory_dict_key = (material_resource,\n + \'\\n\'.join(sorted(material.getVariationCategoryList())),\n + movement.getSource())\n +\n + quantity = material.getQuantity()\n +\n + try:\n + obj = inventory_dict[inventory_dict_key]\n + except KeyError:\n + obj = material\n + result_list.append(obj)\n + else:\n + inventory_quantity_unit = obj.getQuantityUnit()\n + quantity_unit = material.getQuantityUnit()\n + if quantity_unit != inventory_quantity_unit:\n + quantity = material.getResourceValue().convertQuantity(quantity,\n + quantity_unit,\n + inventory_quantity_unit)\n +\n + if quantity:\n + consumption_dict[obj.getUid()] = quantity * (movement.getQuantity() or 0)\n +\n +# sort result_list\n +transformation_allowed_content_type_list = context.portal_types[\'Transformation\'].getTypeAllowedContentTypeList()\n +def compare(a, b):\n + return cmp((consumption_dict.has_key(a.getUid()), a.portal_type in transformation_allowed_content_type_list),\n + (consumption_dict.has_key(b.getUid()), b.portal_type in transformation_allowed_content_type_list),\n + )\n +result_list.sort(cmp=compare, reverse=True)\n +\n +context.REQUEST.set(\'consumption_dict\', consumption_dict)\n +return result_list\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>resource_portal_type, *args,**kwargs</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>ProductionOrder_getConsumptionMovementList</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrder_getMaterialFutureInventoryList.xml b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrder_getMaterialFutureInventoryList.xml index 8609cf5f87a1bb2777d4bd1a8f7e617347adef09..e710bba03a139f176df4f1563346d606c700091c 100644 --- a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrder_getMaterialFutureInventoryList.xml +++ b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrder_getMaterialFutureInventoryList.xml @@ -50,79 +50,9 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>"""Returns list of resources\' inventories used in consumption for production\n - Show only resources which are defined in transformation.\n -"""\n -movement_list = context.getMovementList()\n -transformation_line_list_dict = {}\n -consumed_resource_list = []\n -for movement in movement_list:\n - transformation = movement.getSpecialiseValue()\n - if transformation is not None:\n - transformation_line_list = transformation.objectValues()\n - transformation_line_list_dict[movement] = transformation_line_list\n - for transformation_line in transformation_line_list:\n - transformation_resource = transformation_line.getResourceValue()\n - if transformation_resource is not None:\n - consumed_resource_list.append(transformation_resource)\n - else:\n - transformation_line_list_dict[movement] = ()\n -\n -if not consumed_resource_list:\n - return ()\n -\n -kwargs[\'resource\'] = [resource.getRelativeUrl() for resource in consumed_resource_list]\n -kwargs[\'group_by_section\'] = 0\n -kwargs[\'group_by_node\'] = 1\n -kwargs[\'group_by_variation\'] = 1\n -kwargs[\'section_uid\'] = context.getSourceSectionUid()\n -\n -inventory_dict = {}\n -for inventory in context.portal_simulation.getFutureInventoryList(*args,**kwargs):\n - inventory_dict[inventory.resource_relative_url,\n - inventory.variation_text,\n - inventory.node_relative_url] = inventory\n -\n -result_list = inventory_dict.values()\n -consumption_dict = {}\n -for movement in movement_list:\n - for material in transformation_line_list_dict[movement]:\n - material_resource = material.getResource()\n - if material_resource is None:\n - continue\n -\n - inventory_dict_key = (material_resource,\n - \'\\n\'.join(sorted(material.getVariationCategoryList())),\n - movement.getSource())\n -\n - quantity = material.getQuantity()\n -\n - try:\n - obj = inventory_dict[inventory_dict_key]\n - except KeyError:\n - obj = material\n - result_list.append(obj)\n - else:\n - inventory_quantity_unit = obj.getQuantityUnit()\n - quantity_unit = material.getQuantityUnit()\n - if quantity_unit != inventory_quantity_unit:\n - quantity = material.getResourceValue().convertQuantity(quantity,\n - quantity_unit,\n - inventory_quantity_unit)\n -\n - if quantity:\n - consumption_dict[obj.getUid()] = quantity * (movement.getQuantity() or 0)\n -\n -# sort result_list\n -transformation_allowed_content_type_list = context.portal_types[\'Transformation\'].getTypeAllowedContentTypeList()\n -def compare(a, b):\n - return cmp((consumption_dict.has_key(a.getUid()), a.portal_type in transformation_allowed_content_type_list),\n - (consumption_dict.has_key(b.getUid()), b.portal_type in transformation_allowed_content_type_list),\n - )\n -result_list.sort(cmp=compare, reverse=True)\n -\n -context.REQUEST.set(\'consumption_dict\', consumption_dict)\n -return result_list\n + <value> <string>"""Returns list of products\' inventories used in consumption for production"""\n +kwargs[\'resource_portal_type\'] = context.getPortalObject().getPortalProductTypeList()\n +return context.ProductionOrder_getConsumptionMovementList(*args,**kwargs)\n </string> </value> </item> <item> diff --git a/bt5/erp5_mrp/bt/revision b/bt5/erp5_mrp/bt/revision index 941d0e591f298ec5df6cec8484dac4cda1c255ac..7ad80225027a26278893c2ea0e8f1b2bae19b6dd 100644 --- a/bt5/erp5_mrp/bt/revision +++ b/bt5/erp5_mrp/bt/revision @@ -1 +1 @@ -479 \ No newline at end of file +480 \ No newline at end of file