处理功能刀具预警时没有创建功能刀具预警记录和功能刀具拆解单bug
This commit is contained in:
@@ -445,32 +445,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
shelfinfo = list(filter(lambda x: x.get('DeviceId') == DeciveId,
|
shelfinfo = list(filter(lambda x: x.get('DeviceId') == DeciveId,
|
||||||
request.env['sf.shelf.location'].sudo().get_sf_shelf_location_info(
|
request.env['sf.shelf.location'].sudo().get_sf_shelf_location_info(
|
||||||
DeciveId)))
|
DeciveId)))
|
||||||
total_data = request.env['sf.shelf.location.datasync'].sudo().get_total_data()
|
request.env['sf.shelf.location.datasync'].sudo().set_shelf_location(shelfinfo)
|
||||||
for item in shelfinfo:
|
|
||||||
logging.info('货架已获取信息:%s' % item)
|
|
||||||
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 = request.env['sf.functional.cutting.tool.entity'].sudo().search(
|
|
||||||
[('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')])
|
|
||||||
tool.sudo().tool_in_out_stock_location(location_id)
|
|
||||||
if tool:
|
|
||||||
location_id.product_sn_id = tool.barcode_id.id
|
|
||||||
# 修改功能刀具状态
|
|
||||||
if item.get('State') == '报警':
|
|
||||||
if tool.functional_tool_status != item.get('State'):
|
|
||||||
tool.write({
|
|
||||||
'functional_tool_status': item['State']
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
location_id.product_sn_id = False
|
|
||||||
if item['RfidCode']:
|
|
||||||
logging.info('Rfid为【%s】的功能刀具在系统中不存在!' % item['RfidCode'])
|
|
||||||
else:
|
else:
|
||||||
equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', DeciveId)])
|
equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', DeciveId)])
|
||||||
if equipment_id:
|
if equipment_id:
|
||||||
|
|||||||
@@ -58,20 +58,6 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
|
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
|
||||||
string='功能刀具安全库存', readonly=True)
|
string='功能刀具安全库存', readonly=True)
|
||||||
|
|
||||||
@api.onchange('functional_tool_status')
|
|
||||||
def _onchange_functional_tool_status(self):
|
|
||||||
for item in self:
|
|
||||||
if item:
|
|
||||||
if item.functional_tool_status == '报警':
|
|
||||||
self.create_tool_dismantle()
|
|
||||||
|
|
||||||
def set_functional_tool_status(self):
|
|
||||||
# self.write({
|
|
||||||
# 'functional_tool_status': '报警'
|
|
||||||
# })
|
|
||||||
self.functional_tool_status = '报警'
|
|
||||||
self.create_tool_dismantle()
|
|
||||||
|
|
||||||
def create_tool_dismantle(self):
|
def create_tool_dismantle(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
# 创建报警刀具拆解单
|
# 创建报警刀具拆解单
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form create="0" edit="0" delete="0">
|
<form create="0" edit="0" delete="0">
|
||||||
<header>
|
<header>
|
||||||
<button name="set_functional_tool_status" string="报警" type="object" invisible="1"/>
|
|
||||||
<!-- <button name="enroll_functional_tool_entity" string="功能刀具注册" type="object"-->
|
<!-- <button name="enroll_functional_tool_entity" string="功能刀具注册" type="object"-->
|
||||||
<!-- class="btn-primary"/>-->
|
<!-- class="btn-primary"/>-->
|
||||||
<field name="functional_tool_status" widget="statusbar" statusbar_visible="正常,报警,已拆除"/>
|
<field name="functional_tool_status" widget="statusbar" statusbar_visible="正常,报警,已拆除"/>
|
||||||
|
|||||||
@@ -107,38 +107,47 @@ class MrsShelfLocationDataSync(models.Model):
|
|||||||
equipment_id.register_equipment_tool()
|
equipment_id.register_equipment_tool()
|
||||||
|
|
||||||
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info()
|
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info()
|
||||||
total_data = self.get_total_data()
|
self.set_shelf_location(shelfinfo)
|
||||||
print('shelfinfo:', shelfinfo)
|
|
||||||
for item in shelfinfo:
|
|
||||||
logging.info('货架已获取信息:%s' % item)
|
|
||||||
shelf_barcode = self.find_our_code(total_data, item['Postion'])
|
|
||||||
location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], limit=1)
|
|
||||||
if location_id:
|
|
||||||
# 如果是线边刀库信息,则对功能刀具移动生成记录
|
|
||||||
if 'Tool' in item['Postion']:
|
|
||||||
tool = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
|
||||||
[('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')])
|
|
||||||
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'],
|
|
||||||
'functional_tool_status': item['State'],
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
location_id.product_sn_id = False
|
|
||||||
if item['RfidCode']:
|
|
||||||
logging.info('Rfid为【%s】的功能刀具在系统中不存在!' % item['RfidCode'])
|
|
||||||
else:
|
|
||||||
stock_lot_obj = self.env['stock.lot'].search([('rfid', '=', item['RfidCode'])], limit=1)
|
|
||||||
if stock_lot_obj:
|
|
||||||
location_id.product_sn_id = stock_lot_obj.id
|
|
||||||
else:
|
|
||||||
location_id.product_sn_id = False
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("库区信息同步失败:%s" % e)
|
logging.info("库区信息同步失败:%s" % e)
|
||||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||||
|
|
||||||
|
def set_shelf_location(self, shelfinfo):
|
||||||
|
print('shelfinfo:', shelfinfo)
|
||||||
|
total_data = self.get_total_data()
|
||||||
|
for item in shelfinfo:
|
||||||
|
logging.info('货架已获取信息:%s' % item)
|
||||||
|
shelf_barcode = self.env['sf.shelf.location.datasync'].sudo().find_our_code(
|
||||||
|
total_data, item['Postion'])
|
||||||
|
location_id = self.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(
|
||||||
|
[('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')])
|
||||||
|
tool.sudo().tool_in_out_stock_location(location_id)
|
||||||
|
if tool:
|
||||||
|
location_id.product_sn_id = tool.barcode_id.id
|
||||||
|
if item.get('State') == '预警' and tool.functional_tool_status != '预警':
|
||||||
|
# 创建报警刀具拆解单和刀具报警记录
|
||||||
|
tool.create_tool_dismantle()
|
||||||
|
# 修改功能刀具标准状态值和已使用寿命值、功能刀具状态
|
||||||
|
if 'LifeStd' in item and 'LifeUse' in item:
|
||||||
|
tool.sudo().write({
|
||||||
|
'max_lifetime_value': item['LifeStd'],
|
||||||
|
'used_value': item['LifeUse'],
|
||||||
|
'functional_tool_status': item['State'],
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
location_id.product_sn_id = False
|
||||||
|
if item['RfidCode']:
|
||||||
|
logging.info('Rfid为【%s】的功能刀具在系统中不存在!' % item['RfidCode'])
|
||||||
|
else:
|
||||||
|
stock_lot_obj = self.env['stock.lot'].search([('rfid', '=', item['RfidCode'])], limit=1)
|
||||||
|
if stock_lot_obj:
|
||||||
|
location_id.product_sn_id = stock_lot_obj.id
|
||||||
|
else:
|
||||||
|
location_id.product_sn_id = False
|
||||||
|
|||||||
Reference in New Issue
Block a user