Accept Merge Request #976: (feature/中控接口注释及工厂数据处理 -> develop)

Merge Request: 中控接口优化及工厂数据处理

Created By: @禹翔辉
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/976
This commit is contained in:
禹翔辉
2024-04-25 14:14:12 +08:00
committed by Coding
11 changed files with 74 additions and 34 deletions

View File

@@ -10,6 +10,7 @@
<searchpanel>
<field name="routing_type" select="multi" string="工序类型" icon="fa-building" enable_counters="1"/>
<field name="state" select="multi" string="状态" icon="fa-building" enable_counters="1"/>
<!-- <field name="manual_quotation" select="multi" string="" icon="fa-building" enable_counters="1"/>-->
</searchpanel>
<!-- <field name="name" filter_domain="['|', '|', ('明确的字段内容', 'ilike', self), ('shortdesc', 'ilike', self), ('name', 'ilike', self)]" string="Theme"/>-->
@@ -19,7 +20,11 @@
<!-- <xpath expr="//search//group//filter[@name='product']" position="before">-->
<!-- <filter string="Tray code" name="traycode" domain="[]" context="{'group_by': 'tray_code'}"/>-->
<!-- </xpath>-->
<xpath expr="//filter[@name='date_start_filter']" position="after">
<separator/>
<filter string="人工编程" name="manual_quotation" domain="[('manual_quotation', '=', True)]"/>
<filter string="自动编程" name="no_manual_quotation" domain="[('manual_quotation', '=', False)]"/>
</xpath>
</field>
</record>
</odoo>

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

@@ -67,6 +67,7 @@
<attribute name="statusbar_visible">progress,pending_cam,pending_processing,pending_era_cam,completed,done
</attribute>
</xpath>
<xpath expr="//sheet//group//group[2]//label" position="before">
<!-- <field name="process_state"/> -->
<field name="state"/>

View File

@@ -23,6 +23,9 @@
<field name="product_id" position="after">
<field name="equipment_id" optional="hide"/>
</field>
<xpath expr="//field[@name='qty_remaining']" position="after">
<field name="manual_quotation" optional="show"/>
</xpath>
<xpath expr="//field[@name='date_planned_start']" position="replace">
<field name="date_planned_start" string="计划开始日期" optional="show"/>
</xpath>
@@ -174,6 +177,8 @@
attrs="{'invisible': [('production_state','=', 'draft')], 'readonly': [('is_user_working', '=', True)]}"
sum="real duration"/>
<field name="glb_file" readonly="1" widget="Viewer3D" string="加工模型"/>
<field name="manual_quotation" readonly="1"
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
<field name="processing_panel" readonly="1"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="equipment_id"

View File

@@ -19,6 +19,31 @@
<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>
<record id="search_product_lot_view" model="ir.ui.view">
<field name="name">stock.production.lot.view</field>
<field name="model">stock.lot</field>
<field name="inherit_id" ref="stock.search_product_lot_filter"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="rfid"/>
</xpath>
</field>
</record>
<record id="view_production_lot_view_tree_tree" model="ir.ui.view">
<field name="name">stock.production.lot.tree.inherit.product.expiry</field>
<field name="model">stock.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='create_date']" position="after">
<field name="rfid" invisible="1"/>
</xpath>
</field>
</record>
</odoo>

View File

@@ -20,6 +20,9 @@ class QualityCheck(models.Model):
production_id = self.env['mrp.production'].sudo().search([('name', '=', origin)])
rfid = '' if not production_id.workorder_ids else production_id.workorder_ids[-1].rfid_code or ''
val = [rfid]
# todo 需修改
val = ['0037818516']
logging.info('获取到的工单信息%s' % val)
r = requests.post(crea_url, json=val, headers=headers)
ret = r.json()
logging.info('_register_quality_check:%s' % ret)
@@ -28,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

@@ -63,10 +63,11 @@ class SfMaintenanceEquipment(models.Model):
for data in datas:
maintenance_equipment_id = self.search([('name', '=', data['DeviceId'])])
if maintenance_equipment_id:
tool_id = '%s%s' % (data['ToolId'][0:1], data['ToolId'][1:].zfill(2))
equipment_tool_id = self.env['maintenance.equipment.tool'].sudo().search(
[('equipment_id', '=', maintenance_equipment_id.id), ('code', '=', data['ToolId'])])
[('equipment_id', '=', maintenance_equipment_id.id), ('code', '=', tool_id)])
functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
[('rfid', '=', data['RfidCode'])])
[('rfid', '=', str(int(data['RfidCode'])))])
time = None
if data['AddDatetime']:
datatime = str(data['AddDatetime'])

View File

@@ -11,23 +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"
val = {
'DeviceId': knife_plan.machine_table_name,
'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid,
'ToolId': int(knife_plan.cutter_spacing_code_id.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'}