Commit f0e02c79 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

erp5_mrp: add Production Simulation Rule

erp5_mrp: Fix naming to Simulation Movement test Production Simulation Rule

erp5_mrp: Have ProductionSimulationRule works without items

erp5_mrp: Transformation Simulation rules is adapted to use Manufacturing Order
parent ad97fc23
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Rule_view</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5.Document.DeliverySimulationRule import DeliverySimulationRule
from Products.ERP5.mixin.rule import MovementGeneratorMixin
class ProductionSimulationRule(DeliverySimulationRule):
"""
Create own rule to define the transformation that will be used on production order.
"""
def _getMovementGenerator(self, context):
"""
Return the movement generator to use in the expand process
"""
return DeliveryRuleMovementGenerator(applied_rule=context, rule=self)
class DeliveryRuleMovementGenerator(MovementGeneratorMixin):
def _getUpdatePropertyDict(self, input_movement):
# Override default mixin implementation
return {'order': None,
'delivery': None,}
def _getInputMovementList(self, movement_list=None, rounding=None):
parent_simulation_movement = self._applied_rule.getParentValue().asContext()
resource_value = parent_simulation_movement.getResourceValue()
transformation_list = self._applied_rule.getPortalObject().portal_catalog(
portal_type="Transformation",
default_resource_uid=resource_value.getUid(),
validation_state="validated")
if len(transformation_list) > 0:
parent_simulation_movement.setSpecialiseValue(transformation_list[0].getObject(),
portal_type="Transformation")
# We must always produce positive quantities, this is needed to produce
# resources consumed by transformation (when this rule is below a transformation rule)
if parent_simulation_movement.getQuantity() < 0:
parent_simulation_movement.setQuantity(-parent_simulation_movement.getQuantity())
return [parent_simulation_movement]
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ProductionSimulationRule</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.ProductionSimulationRule</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -36,7 +36,17 @@
<portal_type id="Production Packing List Module">
<item>Production Packing List</item>
</portal_type>
<portal_type id="Production Simulation Rule">
<item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item>
<item>Net Converted Quantity Divergence Tester</item>
<item>Specialise Divergence Tester</item>
<item>String Divergence Tester</item>
<item>Variation Divergence Tester</item>
</portal_type>
<portal_type id="Rule Tool">
<item>Production Simulation Rule</item>
<item>Transformation Simulation Rule</item>
<item>Transformation Sourcing Simulation Rule</item>
</portal_type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Base Type" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>content_icon</string> </key>
<value> <string>rule_icon.gif</string> </value>
</item>
<item>
<key> <string>content_meta_type</string> </key>
<value> <string>ERP5 Delivery Simulation Rule</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>An ERP5 Rule...</string> </value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addDeliverySimulationRule</string> </value>
</item>
<item>
<key> <string>filter_content_types</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>rule</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Production Simulation Rule</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>ProductionSimulationRule</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -47,6 +47,14 @@
<type>Production Packing List Line</type>
<workflow>delivery_movement_causality_interaction_workflow, delivery_movement_simulation_interaction_workflow, edit_workflow, production_matrix_workflow</workflow>
</chain>
<chain>
<type>Production Packing List Module</type>
<workflow>edit_workflow, rule_validation_workflow</workflow>
</chain>
<chain>
<type>Production Simulation Rule</type>
<workflow>edit_workflow, rule_validation_workflow</workflow>
</chain>
<chain>
<type>Transformation Simulation Rule</type>
<workflow>edit_workflow, rule_validation_workflow</workflow>
......
......@@ -6,8 +6,6 @@ if parent.getPortalType() == 'Applied Rule' and movement.getSpecialiseValue(port
if grand_parent.getPortalType() == "Simulation Movement" and \
grand_parent.getDeliveryValue() and \
grand_parent.getDeliveryValue().getPortalType() == "Production Order Line":
resource_value = context.getResourceValue()
if resource_value:
result = (len(resource_value.getAggregatedPortalTypeList()) != 0) and \
("production" in resource_value.getUseList())
resource_value = grand_parent.getDeliveryValue().getResourceValue()
result = resource_value is not None
return result
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SimulationMovement_testProductionManufacturingSimulationRule</string> </value>
<value> <string>SimulationMovement_testProductionSimulationRule</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -2,9 +2,14 @@ specialise_list = context.getSpecialiseValueList(portal_type="Transformation")
if (len(specialise_list) == 1 and
context.getResource() == specialise_list[0].getResource()):
parent = context.getParentValue()
if parent.getSpecialiseValue().getPortalType() == "Delivery Simulation Rule":
movement = context.getParentValue().getDeliveryValue()
parent_specialise_portal_type = parent.getSpecialiseValue().getPortalType()
# Case Manufacturing Order at the root producing a Manufacturing Execution
if (parent_specialise_portal_type == "Order Root Simulation Rule" \
and parent.getCausalityValue().getPortalType() == "Manufacturing Order"):
return True
# Case Manufacturing Order is generated by Simulation
if parent_specialise_portal_type == "Production Simulation Rule":
movement = context.getDeliveryValue()
return movement is not None and movement.getPortalType() in (
"Production Order Line", "Production Order Cell",
"Manufacturing Order Line", "Manufacturing Order Cell")
return False
......@@ -47,6 +47,7 @@ Production Packing List Module | view
Production Packing List | packing_list_print
Production Packing List | view
Production Packing List | view_stock
Production Simulation Rule | view
System Preference | mrp_preference
Transformation Simulation Rule | view
Transformation Sourcing Simulation Rule | view
\ No newline at end of file
document.erp5.ProductionSimulationRule
\ No newline at end of file
......@@ -11,6 +11,14 @@ Production Order | Production Order Line
Production Packing List Line | Production Packing List Cell
Production Packing List Module | Production Packing List
Production Packing List | Production Packing List Line
Production Simulation Rule | Category Membership Divergence Tester
Production Simulation Rule | DateTime Divergence Tester
Production Simulation Rule | Float Divergence Tester
Production Simulation Rule | Net Converted Quantity Divergence Tester
Production Simulation Rule | Specialise Divergence Tester
Production Simulation Rule | String Divergence Tester
Production Simulation Rule | Variation Divergence Tester
Rule Tool | Production Simulation Rule
Rule Tool | Transformation Simulation Rule
Rule Tool | Transformation Sourcing Simulation Rule
Transformation Simulation Rule | Category Membership Divergence Tester
......
......@@ -14,5 +14,6 @@ Production Packing List
Production Packing List Cell
Production Packing List Line
Production Packing List Module
Production Simulation Rule
Transformation Simulation Rule
Transformation Sourcing Simulation Rule
\ No newline at end of file
......@@ -41,11 +41,15 @@ Production Packing List Line | delivery_movement_causality_interaction_workflow
Production Packing List Line | delivery_movement_simulation_interaction_workflow
Production Packing List Line | edit_workflow
Production Packing List Line | production_matrix_workflow
Production Packing List Module | edit_workflow
Production Packing List Module | rule_validation_workflow
Production Packing List | delivery_causality_interaction_workflow
Production Packing List | delivery_causality_workflow
Production Packing List | delivery_simulation_interaction_workflow
Production Packing List | edit_workflow
Production Packing List | production_packing_list_workflow
Production Simulation Rule | edit_workflow
Production Simulation Rule | rule_validation_workflow
Transformation Simulation Rule | edit_workflow
Transformation Simulation Rule | rule_validation_workflow
Transformation Sourcing Simulation Rule | edit_workflow
......
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