1、注释MES装刀指令接口,删除所以该接口的调用;注释质量检测失败时对零件特采接口的调用;2、序列号模型from界面临时添加按钮,解决工厂录入的有些刀柄序列号存在位数少于10的问题(通过SQL在左侧补零)(已隐藏);

This commit is contained in:
yuxianghui
2024-04-25 14:02:51 +08:00
parent 6f2043e7e7
commit 9d96e0681c
7 changed files with 34 additions and 32 deletions

View File

@@ -269,6 +269,13 @@ class ProductionLot(models.Model):
rfid = fields.Char('Rfid', readonly=True)
product_specification = fields.Char('规格', compute='_compute_product_specification', store=True)
def search_lot_put_rfid(self):
# 使用SQL将所有刀柄Rfid不满十位的值在前方补零
self.env.cr.execute(
'''UPDATE stock_lot SET rfid = LPAD(rfid, 10, '0') WHERE rfid IS NOT NULL AND LENGTH(rfid) < 10'''
)
self.env.cr.commit()
@api.depends('product_id')
def _compute_product_specification(self):
for stock in self:

View File

@@ -19,6 +19,9 @@
<xpath expr="//field[@name='product_id']" position="after">
<field name="product_specification"/>
</xpath>
<xpath expr="//field[@name='qr_code_image']" position="after">
<button name="search_lot_put_rfid" string="Rfid补零" type="object" invisible="1"/>
</xpath>
</field>
</record>

View File

@@ -31,10 +31,10 @@ class QualityCheck(models.Model):
else:
raise ValidationError("零件特采发送失败")
def do_fail(self):
self.write({
'quality_state': 'fail',
'user_id': self.env.user.id,
'control_date': datetime.now()})
if self.picking_id and 'WH/MO/' in self.picking_id.origin:
self._register_quality_check()
# def do_fail(self):
# self.write({
# 'quality_state': 'fail',
# 'user_id': self.env.user.id,
# 'control_date': datetime.now()})
# if self.picking_id and 'WH/MO/' in self.picking_id.origin:
# self._register_quality_check()

View File

@@ -258,10 +258,6 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(names)
def knife_plan_cnc_processing(self):
# MES装刀指令接口 測試
self.env['sf.cnc.processing'].register_cnc_processing(self)
def apply_for_tooling(self):
"""
申请装刀

View File

@@ -11,24 +11,23 @@ class CNCprocessing(models.Model):
_description = 'CNC加工用刀检测'
# ==========MES装刀指令接口==========
def register_cnc_processing(self, knife_plan):
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/ToolLoadInstruct"
# todo
val = {
'DeviceId': knife_plan.machine_table_name,
'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid.zfill(10),
'ToolId': int(knife_plan.cam_cutter_spacing_code[1:])
}
r = requests.post(crea_url, json=val, headers=headers)
ret = r.json()
logging.info('register_cnc_processing:%s' % ret)
if ret['Succeed']:
return "MES装刀指令发送成功"
else:
raise ValidationError("MES装刀指令发送失败")
# def register_cnc_processing(self, knife_plan):
# 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/ToolLoadInstruct"
# val = {
# 'DeviceId': knife_plan.machine_table_name,
# 'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid.zfill(10),
# 'ToolId': int(knife_plan.cam_cutter_spacing_code[1:])
# }
# r = requests.post(crea_url, json=val, headers=headers)
# ret = r.json()
# logging.info('register_cnc_processing:%s' % ret)
# if ret['Succeed']:
# return "MES装刀指令发送成功"
# else:
# raise ValidationError("MES装刀指令发送失败")
@api.model_create_multi
def create(self, vals):

View File

@@ -321,8 +321,6 @@
attrs="{'invisible': [('plan_execute_status', '!=', '0')]}" confirm="是否确认申请装刀"/>
<button string="撤回" name="revocation" type="object" class="btn-primary"
attrs="{'invisible': [('plan_execute_status', '!=', '1')]}" confirm="是否确认撤回装刀"/>
<button string="发起中控装刀" name="knife_plan_cnc_processing" type="object" class="btn-primary"
attrs="{'invisible': [('plan_execute_status', '!=', '2')]}"/>
<field name="plan_execute_status" widget="statusbar" statusbar_visible="0,1,2"/>
</header>

View File

@@ -602,7 +602,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
('id', '=', functional_tool_assembly.sf_cam_work_order_program_knife_plan_id.id)
])
cam_plan.write({'plan_execute_status': '2'})
self.env['sf.cnc.processing'].register_cnc_processing(cam_plan)
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}