diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 6be34597..93d080a6 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -370,6 +370,7 @@ class Manufacturing_Connect(http.Controller): res = {'Succeed': True, 'Datas': []} datas = request.httprequest.data ret = json.loads(datas) + logging.info('LocationChange_ret===========:%s' % ret) RfidCode = ret['RfidCode'] ChangeType = ret['ChangeType'] OldDeciveId = ret['OldDeciveId'] @@ -381,26 +382,32 @@ class Manufacturing_Connect(http.Controller): temp_val_sn_id = None old_localtion = None - if ChangeType == 'Part' or ChangeType == 'Tool': - stock_lot_obj = request.env['stock.lot'].sudo().search( - [('rfid', '=', RfidCode)], limit=1) - if not stock_lot_obj: - res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该产品'} - return json.JSONEncoder().encode(res) - if OldPosition: - old_localtion = request.env['sf.shelf.location'].sudo().search( - [('barcode', '=', OldPosition)], limit=1) - new_localtion = request.env['sf.shelf.location'].sudo().search( - [('barcode', '=', NewPosition)], limit=1) - if not new_localtion: - res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'} - return json.JSONEncoder().encode(res) - if old_localtion: - temp_val_sn_id = old_localtion.product_sn_id - old_localtion.product_sn_id = None - new_localtion.product_sn_id = temp_val_sn_id - else: - new_localtion.product_sn_id = stock_lot_obj.id + # if ChangeType == 'Part' or ChangeType == 'Tool': + stock_lot_obj = request.env['stock.lot'].sudo().search( + [('rfid', '=', RfidCode)], limit=1) + logging.info('stock_lot_obj===========:%s' % stock_lot_obj) + if not stock_lot_obj: + res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该产品'} + return json.JSONEncoder().encode(res) + if OldPosition: + old_localtion = request.env['sf.shelf.location'].sudo().search( + [('barcode', '=', OldPosition)], limit=1) + logging.info('old_localtion===========:%s' % old_localtion) + new_localtion = request.env['sf.shelf.location'].sudo().search( + [('barcode', '=', NewPosition)], limit=1) + logging.info('new_localtion===========:%s' % new_localtion) + if not new_localtion: + res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'} + return json.JSONEncoder().encode(res) + if old_localtion: + temp_val_sn_id = old_localtion.product_sn_id + logging.info('temp_val_sn_id===========:%s' % temp_val_sn_id) + old_localtion.product_sn_id = None + new_localtion.product_sn_id = temp_val_sn_id + logging.info('====1======') + else: + new_localtion.product_sn_id = stock_lot_obj.id + logging.info('=====2======') except Exception as e: res = {'Succeed': False, 'ErrorCode': 202, 'Error': e} logging.info('LocationChange error:%s' % e)