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