diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py
index 64b51b50..b7d3af13 100644
--- a/sf_manufacturing/controllers/controllers.py
+++ b/sf_manufacturing/controllers/controllers.py
@@ -65,6 +65,7 @@ class Manufacturing_Connect(http.Controller):
else:
ProductionLine = False
workorder_ids = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
+ # todo 需要筛选出CNC工单
logging.info('RfidCode:%s' % ret)
logging.info('workorder_ids:%s' % workorder_ids)
workorder = request.env['mrp.workorder'].sudo().search(workorder_ids)
@@ -377,37 +378,75 @@ class Manufacturing_Connect(http.Controller):
NewPosition = ret['NewPosition']
OldDeciveStart = ret['OldDeciveStart']
OldDeciveEnd = ret['OldDeciveEnd']
+
+ temp_val_sn_id = None
+ old_localtion = None
# Part、Tool
- if ChangeType == 'Part':
- workorder = request.env['mrp.workorder'].sudo().search(
- [('rfid_code', '=', RfidCode)], limit=1)
- if not workorder:
- res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该工单'}
+ # if ChangeType == 'Part':
+ # workorder = request.env['mrp.workorder'].sudo().search(
+ # [('rfid_code', '=', RfidCode)], limit=1)
+ # if not workorder:
+ # res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该工单'}
+ # return json.JSONEncoder().encode(res)
+ # 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:
+ # old_localtion.location_status = '空闲'
+ # old_localtion.production_id = False
+ # new_localtion.location_status = '占用'
+ # new_localtion.production_id = workorder.production_id.id
+ # if ChangeType == 'Tool':
+ # old_localtion = request.env['sf.shelf.location'].sudo().search(
+ # [('barcode', '=', OldPosition)], limit=1)
+ # equipment_id = request.env['maintenance.equipment'].sudo().search(
+ # [('name', '=', NewPosition)], limit=1)
+ # equipment_id.register_equipment_tool()
+ # if not equipment_id:
+ # res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'}
+ # return json.JSONEncoder().encode(res)
+ # if old_localtion:
+ # old_localtion.location_status = '空闲'
+ # old_localtion.production_id = False
+ #
+ # # return json.JSONEncoder().encode(res)
+ # # else:
+ # # res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
+ 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)
- old_localtion = request.env['sf.shelf.location'].sudo().search(
- [('barcode', '=', OldPosition)], limit=1)
+ 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:
- old_localtion.location_status = '空闲'
- old_localtion.production_id = False
- new_localtion.location_status = '占用'
- new_localtion.production_id = workorder.production_id.id
- if ChangeType == 'Tool':
- old_localtion = request.env['sf.shelf.location'].sudo().search(
- [('barcode', '=', OldPosition)], limit=1)
- equipment_id = request.env['maintenance.equipment'].sudo().search(
- [('name', '=', NewPosition)], limit=1)
- equipment_id.register_equipment_tool()
- if not equipment_id:
- res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'}
- return json.JSONEncoder().encode(res)
- if old_localtion:
- old_localtion.location_status = '空闲'
- old_localtion.production_id = False
+ 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 == 'Tool':
+ # old_localtion = request.env['sf.shelf.location'].sudo().search(
+ # [('barcode', '=', OldPosition)], limit=1)
+ # equipment_id = request.env['maintenance.equipment'].sudo().search(
+ # [('name', '=', NewPosition)], limit=1)
+ # equipment_id.register_equipment_tool()
+ # if not equipment_id:
+ # res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'}
+ # return json.JSONEncoder().encode(res)
+ # if old_localtion:
+ # old_localtion.product_sn_id = None
# return json.JSONEncoder().encode(res)
# else:
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index fccc4301..61461dde 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -113,7 +113,8 @@ class MrpProduction(models.Model):
if production.state == 'progress' and production.schedule_state == '已排':
# production.state = 'pending_processing'
production.state = 'pending_cam'
- elif production.state == 'pending_cam' and production.process_state == '待加工':
+ if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待加工':
+ # if production.state == 'pending_cam' and production.process_state == '待加工':
production.state = 'pending_processing'
elif production.state == 'pending_processing' and production.process_state == '待解除装夹':
production.state = 'pending_era_cam'
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 63c66577..2ce9a2f6 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -406,9 +406,10 @@ class ResMrpWorkOrder(models.Model):
work = workorder.production_id.workorder_ids
work.compensation_value_x = eval(self.material_center_point)[0]
work.compensation_value_y = eval(self.material_center_point)[1]
+ work.process_state = '待加工'
+ self.sudo().production_id.state = 'pending_processing'
workorder.button_finish()
- self.process_state = '待加工'
- # self.sudo().production_id.state = 'pending_processing'
+
except Exception as e:
# 重新抛出捕获到的异常信息
raise UserError(str(e))
diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml
index 90cee94b..47af7c2d 100644
--- a/sf_manufacturing/views/mrp_production_addional_change.xml
+++ b/sf_manufacturing/views/mrp_production_addional_change.xml
@@ -70,6 +70,7 @@
+
diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py
index a9f88c26..42ff8157 100644
--- a/sf_plan/models/custom_plan.py
+++ b/sf_plan/models/custom_plan.py
@@ -294,10 +294,10 @@ class sf_production_plan(models.Model):
print('时间设置失败,请检查是否为工序分配工作中心,%s' % e)
def cancel_production_schedule(self):
- self.date_planned_start = False
- self.date_planned_finished = False
+ self.date_planned_start = None
+ self.date_planned_finished = None
self.state = 'draft'
- self.production_line_id = False
+ self.production_line_id = None
aa = self.env['mrp.production'].sudo().search([('name', '=', self.name)])
aa.schedule_state = '未排'
# self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to shedule'
diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py
index 50469284..3a98116a 100644
--- a/sf_warehouse/models/model.py
+++ b/sf_warehouse/models/model.py
@@ -500,8 +500,12 @@ class ShelfLocation(models.Model):
# sf_secret_key = sf_sync_config['sf_secret_key']
# headers = Common.get_headers(self, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + self.crea_url
- headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
- crea_url = 'https://x24467i973.zicp.fun/AutoDeviceApi/GetLocationInfos'
+ config = self.env['res.config.settings'].get_values()
+ # token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
+ headers = {'Authorization': config['center_control_Authorization']}
+ crea_url = config['center_control_url'] + "/AutoDeviceApi/GetLocationInfos"
+ # headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603'}
+ # crea_url = 'https://x24467i973.zicp.fun/AutoDeviceApi/GetLocationInfos'
# objs_all = self.env['maintenance.equipment'].search([('id', '=', self.id)])
# machine_tool_list = []