diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 8075f126..50ad39b1 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -386,7 +386,7 @@ class Manufacturing_Connect(http.Controller): ret = json.loads(datas) request.env['center_control.interface.log'].sudo().create( {'content': ret, 'name': 'AutoDeviceApi/LocationChange'}) - logging.info('LocationChange_ret===========:%s' % ret) + logging.info('库位变更LocationChange_ret:%s' % ret) RfidCode = ret['RfidCode'] ChangeType = ret['ChangeType'] OldDeciveId = ret['OldDeciveId'] @@ -429,25 +429,36 @@ class Manufacturing_Connect(http.Controller): # 对功能刀具库位变更信息进行更改 def write_tool(DeciveId): if 'Tool' in DeciveId: - shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info(DeciveId) + shelfinfo = list(filter(lambda x: x.get('DeviceId') == DeciveId, + request.env['sf.shelf.location'].sudo().get_sf_shelf_location_info( + DeciveId))) + total_data = request.env['sf.shelf.location.datasync'].sudo().get_total_data() for item in shelfinfo: - shelf_barcode = self.env['sf.shelf.location.datasync'].find_our_code(item['Postion']) - location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], - limit=1) + shelf_barcode = request.env['sf.shelf.location.datasync'].sudo().find_our_code( + total_data, item['Postion']) + location_id = request.env['sf.shelf.location'].sudo().search( + [('barcode', '=', shelf_barcode)], + limit=1) if location_id: # 如果是线边刀库信息,则对功能刀具移动生成记录 if 'Tool' in item['Postion']: - tool = self.env['sf.functional.cutting.tool.entity'].sudo().search( + tool = request.env['sf.functional.cutting.tool.entity'].sudo().search( [('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')]) - tool.tool_in_out_stock_location(location_id) + tool.sudo().tool_in_out_stock_location(location_id) if tool: location_id.product_sn_id = tool.barcode_id.id + # 修改功能刀具状态 + # tool_install_time = {'Nomal': '正常', 'Warning': '报警'} + # tool.write({ + # 'functional_tool_status': tool_install_time.get(item['State']) + # }) else: location_id.product_sn_id = False + logging.info('货架已获取信息:%s' % item) else: - equipment_id = self.env['maintenance.equipment'].search([('name', '=', DeciveId)]) + equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', DeciveId)]) if equipment_id: - equipment_id.register_equipment_tool() + equipment_id.sudo().register_equipment_tool() else: res_1 = {'Succeed': False, 'ErrorCode': 202, 'Error': f'设备【{DeciveId}】不存在'} return json.JSONEncoder().encode(res_1) diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 75e2d0c1..ce27a4df 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -42,12 +42,12 @@