Merge branch 'feature/销售委外加工按钮优化_1' into feature/中控接口优化
This commit is contained in:
@@ -744,21 +744,25 @@ class ResMrpWorkOrder(models.Model):
|
||||
# self.workpiece_delivery_ids[0].write({'rfid_code': self.rfid_code})
|
||||
|
||||
def get_plan_workorder(self, production_line):
|
||||
tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d")
|
||||
tomorrow_start = tomorrow + ' 00:00:00'
|
||||
tomorrow_end = tomorrow + ' 23:59:59'
|
||||
tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d")
|
||||
tomorrow_start = f"{tomorrow} 00:00:00"
|
||||
tomorrow_end = f"{tomorrow} 23:59:59"
|
||||
logging.info('tomorrow:%s' % tomorrow)
|
||||
sql = """
|
||||
SELECT *
|
||||
FROM mrp_workorder
|
||||
WHERE state!='rework'
|
||||
to_char(date_planned_start::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')>= %s
|
||||
AND to_char(date_planned_finished::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')<= %s
|
||||
AND (date_planned_start + interval '8 hours') >= %s::timestamp
|
||||
AND (date_planned_finished + interval '8 hours') <= %s::timestamp
|
||||
"""
|
||||
params = [tomorrow_start, tomorrow_end]
|
||||
if production_line:
|
||||
line = self.env['sf.production.line'].search(
|
||||
[('name', '=', production_line)], limit=1)
|
||||
if not line:
|
||||
raise ValueError(f"生产线'{production_line}'不存在")
|
||||
sql += "AND production_line_id = %s"
|
||||
params.append(production_line)
|
||||
params.append(line.id)
|
||||
self.env.cr.execute(sql, params)
|
||||
ids = [t[0] for t in self.env.cr.fetchall()]
|
||||
return [('id', 'in', ids)]
|
||||
|
||||
@@ -150,6 +150,17 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
else:
|
||||
# 原刀从线边出库
|
||||
item.tool_in_out_stock_location_1(location_id, tool_room_id)
|
||||
# 系统中该刀在线边刀架其他位置,需先清除这个位置的刀具信息
|
||||
shelf_location_id = self.env['sf.shelf.location'].sudo().search([
|
||||
('product_sn_id', '=', item.barcode_id.id)])
|
||||
if shelf_location_id:
|
||||
shelf_location_id.write(
|
||||
{'product_id': None,
|
||||
'product_sn_id': None,
|
||||
'tool_rfid': None,
|
||||
"tool_name_id": None,
|
||||
'product_num': 0,
|
||||
'location_status': '空闲'})
|
||||
# 新刀入库到线边
|
||||
item.create_stock_move(pre_manufacturing_id, location_id)
|
||||
item.current_shelf_location_id = location_id.id
|
||||
|
||||
@@ -121,10 +121,16 @@ class MrsShelfLocationDataSync(models.Model):
|
||||
tool.tool_in_out_stock_location(location_id)
|
||||
if tool:
|
||||
location_id.product_sn_id = tool.barcode_id.id
|
||||
# 修改功能刀具标准状态值和已使用寿命值
|
||||
if 'LifeStd' in item and 'LifeUse' in item:
|
||||
tool.sudo().write({
|
||||
'max_lifetime_value': item['LifeStd'],
|
||||
'used_value': item['LifeUse']
|
||||
})
|
||||
# 修改功能刀具状态
|
||||
if item.get('State') == '报警':
|
||||
if tool.functional_tool_status != item.get('State'):
|
||||
tool.write({
|
||||
tool.sudo().write({
|
||||
'functional_tool_status': item['State']
|
||||
})
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user