Commit 3422c83e authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_mrp_quality_assurance: constraint

parent 932ee3d1
......@@ -11,6 +11,9 @@
<portal_type id="Gate">
<item>SortIndex</item>
</portal_type>
<portal_type id="Manufacturing Execution Line">
<item>DeliveryLine_qualityAssuranceConstraint</item>
</portal_type>
<portal_type id="Quality Control">
<item>SortIndex</item>
</portal_type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DeliveryLine_qualityAssuranceConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/default</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>quality_assurance_element_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>DeliveryLine_checkQualityAssuranceElement</string> </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/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
ledger = context.getLedger()
if ledger not in ("manufacturing/quality_insurance", "manufacturing/electronic_insurance"):
return []
if context.getQuantity() > 0:
return []
if ledger == "manufacturing/quality_insurance":
publication_section = "quality_insurance"
else:
publication_section = "electronic_insurance"
resource_value = context.getResourceValue()
if not resource_value:
return []
resource_use = resource_value.getUse()
use_dict = {
"manufacturing/defect_notification": "",
"manufacturing/quality_insurance":"",
"manufacturing/gate": "Gate",
"manufacturing/traceability": "Traceability",
"manufacturing/quality_control": "Quality Control",
"manufacturing/smon": "SMON",
"manufacturing/acom": "ACOM"
}
if resource_use not in use_dict:
return ['resource use: %s not in use dict: %s' % (resource_use, use_dict.keys())]
if resource_use in ("manufacturing/quality_insurance", "manufacturing/defect_notification"):
return []
portal_type=use_dict[resource_use]
ME_insurance = context.getParentValue()
production_order = ME_insurance.getCausalityValue(portal_type='Production Order')
for me in production_order.getCausalityRelatedValueList(portal_type='Manufacturing Execution'):
if me.getLedger() == 'manufacturing/execution':
ME_execution = me
break
vin = ME_execution.getAggregateValue(portal_type='VIN')
if portal_type == "Traceability":
if not context.getAggregateValue(portal_type=portal_type):
if not fixit:
return ['No quality assurance element found']
if ME_insurance.getLedger() == "manufacturing/quality_insurance":
product_reference = resource_value.getReference().split('-')[-1]
else:
product_reference = resource_value.getReference()
document_title = resource_value.getTitle()
assurance_document = context.quality_assurance_module.newContent(
portal_type=portal_type,
title = document_title,
reference = product_reference,
int_index = context.getIntIndex(),
description = resource_value.getDescription(),
causality_value = ME_execution,
aggregate_value = vin,
effective_date = DateTime(),
publication_section = publication_section
)
if ME_insurance.getLedger() == "manufacturing/quality_insurance":
# check if really in BOM
real_line = ME_execution.searchFolder(
portal_type='Manufacturing Execution Line',
limit=1,
strict_resource_reference = product_reference)
if real_line:
assurance_document.edit(follow_up_value = real_line[0])
context.setAggregateValue(assurance_document, portal_type=portal_type)
assurance_document.plan()
return []
else:
if not context.getAggregateValue(portal_type=portal_type):
if not fixit:
return ['No quality assurance element found']
assurance_document = context.quality_assurance_module.newContent(
portal_type=portal_type,
title = resource_value.getTitle(),
reference = resource_value.getReference(),
int_index = context.getIntIndex(),
description = resource_value.getDescription(),
causality_value = ME_execution,
aggregate_value = vin,
publication_section = publication_section,
effective_date = DateTime()
)
context.setAggregateValue(assurance_document, portal_type=portal_type)
assurance_document.plan()
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>_params</string> </key>
<value> <string>fixit=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DeliveryLine_checkQualityAssuranceElement</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,6 +2,7 @@ ACOM | SortIndex
Defect Correction | SortIndex
Defect Declaration | SortIndex
Gate | SortIndex
Manufacturing Execution Line | DeliveryLine_qualityAssuranceConstraint
Quality Control | SortIndex
SMON | SortIndex
Traceability | SortIndex
\ No newline at end of file
DeliveryLine_qualityAssuranceConstraint
\ 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