Commit 296a591e authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_mrp_quality_assurance: check more before post control and improve message

parent 658eee9c
......@@ -82,8 +82,8 @@
.push(function (response) {
var result = JSON.parse(response.target.result);
return gadget.changeState({
'submit_state': result.status,
'input_value': result.value
'submit_state': result.portal_status_level,
'input_value': result.portal_status_message
});
});
});
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1020.54828.58036.39594</string> </value>
<value> <string>1020.63511.22654.904</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -270,7 +270,7 @@
</tuple>
<state>
<tuple>
<float>1732268943.18</float>
<float>1732789903.27</float>
<string>UTC</string>
</tuple>
</state>
......
from DateTime import DateTime
import json
now = DateTime()
user_value = context.portal_membership.getAuthenticatedMember().getUserValue()
portal = context.getPortalObject()
translateString = portal.Base_translateString
if not portal.portal_membership.checkPermission('Modify portal content', context):
result_dict = {
'portal_status_message': translateString("No Permission"),
'portal_status_level': 'error'
}
if batch or fast_post:
return json.dumps(result_dict)
return context.Base_redirect('view', keep_items = result_dict)
if not portal.portal_workflow.isTransitionPossible(context, 'post'):
result_dict = {
'portal_status_message': translateString("Quality Control is already in ${state} state", mapping={"state": context.getValidationState()}),
'portal_status_level': 'error'
}
if batch or fast_post:
return json.dumps(result_dict)
return context.Base_redirect('view', keep_items = result_dict)
user_value = portal.portal_membership.getAuthenticatedMember().getUserValue()
if result == 'ok':
context.edit(
......@@ -14,8 +37,8 @@ if result == 'ok':
elif result == 'nok':
if fast_post:
return json.dumps({
'status': 'error',
'value': 'Only OK is allow'
'portal_status_message': translateString("Only OK is allowed"),
'portal_status_level': 'error'
})
if not context.getCausalityRelatedValue(portal_type='Defect Item') and redirect_to_defect_dialog:
return context.Base_redirect(form_id = 'declare_defect', keep_items={
......@@ -42,12 +65,13 @@ elif result == 'nok':
effective_date = now
)
else:
if fast_post:
return json.dumps({
'status': 'error',
'value': 'Only OK is allow'
})
raise ValueError('unknown result: %s' % result)
result_dict = {
'portal_status_message': translateString("Unknown Value: ${result}", mapping = {'result': result}),
'portal_status_level': 'error'
}
if batch or fast_post:
return json.dumps(result_dict)
return context.Base_redirect('view', keep_items = result_dict)
me_line = context.getAggregateRelatedValue(portal_type='Manufacturing Execution Line')
if me_line:
......@@ -56,13 +80,11 @@ if me_line:
stop_date = now
)
context.post()
if batch:
return context
if fast_post:
if batch or fast_post:
return json.dumps({
'status': 'success',
'value': 'OK'
'portal_status_message': 'OK',
'portal_status_level': 'success'
})
ME = context.getCausalityValue(portal_type='Manufacturing Execution')
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>result, redirect_to_defect_dialog = True, batch=False, fast_post = False, **kw</string> </value>
<value> <string>result, redirect_to_defect_dialog = True, batch = False, fast_post = False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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