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) rfid = fields.Char('Rfid', readonly=True)
product_specification = fields.Char('规格', compute='_compute_product_specification', store=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') @api.depends('product_id')
def _compute_product_specification(self): def _compute_product_specification(self):
for stock in self: for stock in self:

View File

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

View File

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

View File

@@ -258,10 +258,6 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(names) 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): def apply_for_tooling(self):
""" """
申请装刀 申请装刀

View File

@@ -11,24 +11,23 @@ class CNCprocessing(models.Model):
_description = 'CNC加工用刀检测' _description = 'CNC加工用刀检测'
# ==========MES装刀指令接口========== # ==========MES装刀指令接口==========
def register_cnc_processing(self, knife_plan): # def register_cnc_processing(self, knife_plan):
config = self.env['res.config.settings'].get_values() # config = self.env['res.config.settings'].get_values()
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A] # # token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
headers = {'Authorization': config['center_control_Authorization']} # headers = {'Authorization': config['center_control_Authorization']}
crea_url = config['center_control_url'] + "/AutoDeviceApi/ToolLoadInstruct" # crea_url = config['center_control_url'] + "/AutoDeviceApi/ToolLoadInstruct"
# todo # val = {
val = { # 'DeviceId': knife_plan.machine_table_name,
'DeviceId': knife_plan.machine_table_name, # 'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid.zfill(10),
'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid.zfill(10), # 'ToolId': int(knife_plan.cam_cutter_spacing_code[1:])
'ToolId': int(knife_plan.cam_cutter_spacing_code[1:]) # }
} # r = requests.post(crea_url, json=val, headers=headers)
r = requests.post(crea_url, json=val, headers=headers) # ret = r.json()
ret = r.json() # logging.info('register_cnc_processing:%s' % ret)
logging.info('register_cnc_processing:%s' % ret) # if ret['Succeed']:
if ret['Succeed']: # return "MES装刀指令发送成功"
return "MES装刀指令发送成功" # else:
else: # raise ValidationError("MES装刀指令发送失败")
raise ValidationError("MES装刀指令发送失败")
@api.model_create_multi @api.model_create_multi
def create(self, vals): def create(self, vals):

View File

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

View File

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