工单异常处理
This commit is contained in:
@@ -63,15 +63,8 @@ class SfMrsConnectController(Sf_Mrs_Connect):
|
||||
if res.get('production_ids'):
|
||||
try:
|
||||
productions = request.env['mrp.production'].sudo().search([('id', 'in', res.get('production_ids'))])
|
||||
if productions.workorder_ids.exception_ids:
|
||||
pending_exception = productions.workorder_ids.exception_ids.filtered(
|
||||
lambda exc: exc.state == 'pending' and exc.exception_code in ['YC0001', 'YC0004']
|
||||
)
|
||||
if pending_exception:
|
||||
pending_exception.write({
|
||||
'completion_time': fields.Datetime.now(),
|
||||
'state': 'done'
|
||||
})
|
||||
if productions.workorder_ids:
|
||||
productions.workorder_ids.handle_exception(['YC0001', 'YC0004'])
|
||||
except Exception as e:
|
||||
_logger.info('更新工单异常记录失败:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
@@ -90,17 +83,7 @@ class ManufactruingController(Manufacturing_Connect):
|
||||
if res.get('workorder_id'):
|
||||
try:
|
||||
workorder = request.env['mrp.workorder'].sudo().browse(int(res.get('workorder_id')))
|
||||
if workorder.exception_ids:
|
||||
_logger.info('workorder.exception_ids:%s' % workorder.exception_ids)
|
||||
pending_exception = workorder.exception_ids.filtered(
|
||||
lambda exc: exc.state == 'pending' and exc.exception_code in ['YC0002', 'YC0003']
|
||||
)
|
||||
_logger.info('pending_exception:%s' % pending_exception)
|
||||
if pending_exception:
|
||||
pending_exception.write({
|
||||
'completion_time': fields.Datetime.now(),
|
||||
'state': 'done'
|
||||
})
|
||||
workorder.handle_exception(['YC0002', 'YC0003'])
|
||||
except Exception as e:
|
||||
_logger.info('更新工单异常记录失败:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
Reference in New Issue
Block a user