Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造代码优化

This commit is contained in:
mgw
2024-04-26 15:54:20 +08:00
20 changed files with 283 additions and 162 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

@@ -426,18 +426,33 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('ret:%s' % ret)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination_id.name', '=', ret['DeviceId']),
('status', '=', '已配送'), ('type', '=', '上产线')], order='id asc')
for i in range(1, 5):
logging.info('F-RfidCode:%s' % i)
if f'RfidCode{i}' in ret:
rfid_code = ret[f'RfidCode{i}']
logging.info('RfidCode:%s' % rfid_code)
domain = [
('feeder_station_destination_id.name', '=', ret['DeviceId']),
('workorder_id.rfid_code', '=', rfid_code),
('status', '=', '已配送'),
('type', '=', '上产线')
]
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain, order='id asc')
if workpiece_delivery:
for wd in workpiece_delivery:
logging.info('wd.production_id:%s' % wd.production_id.name)
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
wd.production_id.write({'production_line_state': '已上产线'})
wd.write({'production_line_state': '已上产线'})
next_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
[('workorder_id.rfid_code', '=', rfid_code), ('type', '=', '下产线'),
('production_id', '=', wd.production_id.id)])
if next_workpiece:
logging.info('next_workpiece:%s' % next_workpiece.delivery_num)
next_workpiece.write({'status': '待下发', 'task_delivery_time': datetime.now()})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'}
else:
@@ -461,31 +476,50 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('ret:%s' % ret)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination_id.name', '=', ret['DeviceId']),
('status', '=', '已配送'), ('type', '=', '下产线')], order='id asc')
delivery_Arr = []
for i in range(1, 5):
logging.info('F-RfidCode:%s' % i)
if f'RfidCode{i}' in ret:
rfid_code = ret[f'RfidCode{i}']
logging.info('RfidCode:%s' % rfid_code)
domain = [
('feeder_station_start_id.name', '=', ret['DeviceId']),
('workorder_id.rfid_code', '=', rfid_code),
('status', '=', '待下发'),
('type', '=', '下产线')
]
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain, order='id asc')
if workpiece_delivery:
for wd in workpiece_delivery:
logging.info('wd.production_id:%s' % wd.production_id.name)
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
wd.production_id.write({'production_line_state': '已下产线'})
delivery_Arr.append({wd.id})
next_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
[('workorder_id.rfid_code', '=', rfid_code), ('type', '=', '运送空料架'),
('production_id', '=', wd.production_id.id)])
if next_workpiece:
logging.info('next_workpiece:%s' % next_workpiece.delivery_num)
next_workpiece.write({'status': '待下发', 'task_delivery_time': datetime.now()})
if delivery_Arr:
logging.info('delivery_Arr:%s' % delivery_Arr)
delivery_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
[('id', 'in', delivery_Arr)])
if delivery_workpiece:
logging.info('开始向agv下发下产线任务')
wd._delivery_avg()
logging.info('agv下发下产线任务已配送')
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'}
delivery_workpiece._delivery_avg()
logging.info('agv下发下产线任务下发完成')
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('AGVDownProduct error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/EquipmentBaseCoordinate', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/EquipmentBaseCoordinate', type='json', auth='sf_token', methods=['GET', 'POST'],
csrf=False,
cors="*")
def PutEquipmentBaseCoordinate(self, **kw):
"""

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import logging
import json
from datetime import datetime
from odoo import http
from odoo.http import request
@@ -24,14 +25,16 @@ class Workpiece(http.Controller):
if 'reqCode' in ret:
if 'method' in ret:
if ret['method'] == 'end':
logging.info('backfeed-ret:%s' % ret['reqCode'].rsplit('-', 1)[0])
req_codes = ret['reqCode'].split(',')
for req_code in req_codes:
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('production_id.name', '=', ret['reqCode'].rsplit('-', 1)[0]), ('delivery_num', '=',
ret['reqCode'])])
[('production_id.name', '=', req_code.rsplit('-', 1)[0]),
('delivery_num', '=', req_code.strip())])
if workpiece_delivery:
workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']})
workpiece_delivery.write({'status': '已配送', 'task_completion_time': datetime.now()})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该reqCode暂未查到对应的工件配送记录'}
res = {'Succeed': False, 'ErrorCode': 203,
'Error': '该reqCode暂未查到对应的工件配送记录'}
else:
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '未传method字段'}
else:

View File

@@ -172,6 +172,7 @@ class ResMrpWorkOrder(models.Model):
is_delivery = fields.Boolean('是否配送完成', default=False)
rfid_code = fields.Char('RFID码')
rfid_code_old = fields.Char('RFID码(已解除)')
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
string='生产线', store=True)
production_line_state = fields.Selection(related='production_id.production_line_state',
@@ -419,10 +420,8 @@ class ResMrpWorkOrder(models.Model):
for item in self.workpiece_delivery_ids:
if not item.route_id:
raise UserError('【工件配送】明细中请选择【任务路线】')
# if not item.workpiece_code:
# raise UserError('请对【同运工件】进行扫描')
else:
if self.cnc_program_down_state == '已下发':
if item.is_cnc_program_down is True:
if item.status == '待下发':
return {
'name': _('确认'),
@@ -773,6 +772,7 @@ class ResMrpWorkOrder(models.Model):
raise UserError("请对前置三元检测定位参数进行计算定位")
if not self.rfid_code:
raise UserError("请扫RFID码进行绑定")
self.workpiece_delivery_ids[0].write({'status': '待下发'})
if self.picking_out_id:
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
if picking_out.workorder_out_id:
@@ -901,6 +901,11 @@ class CNCprocessing(models.Model):
# cnc_workorder.state = 'done'
cnc_workorder.work_state = '已编程'
cnc_workorder.programming_state = '已编程'
workpiece_delivery = self.env['sf.workpiece.delivery'].search(
[('production_id', '=', cnc_workorder.id)])
if workpiece_delivery:
for item in workpiece_delivery:
item.is_cnc_program_down = True
# cnc_workorder.time_ids.date_end = datetime.now()
# cnc_workorder.button_finish()
@@ -985,20 +990,11 @@ class SfWorkOrderBarcodes(models.Model):
def on_barcode_scanned(self, barcode):
workorder = self.env['mrp.workorder'].browse(self.ids)
workorder_preset = self.env['mrp.workorder'].search(
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', barcode)])
# workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
if len(workorder_preset) <= 4:
workpiece_ids = []
for item in workorder_preset:
if item.production_line_id.id == workorder.production_line_id.id:
workpiece_ids.append(item.production_id.id)
else:
raise UserError('工件生产线不一致,请重新确认')
if workpiece_ids:
workorder.workpiece_delivery_ids.write({'sametransport_production_ids': [(6, 0, workpiece_ids)]})
# raise UserError('该托盘已绑定【%s】制造订单请先解除绑定' % workorder_old.production_id.name)
# workorder_preset = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('rfid_code', '=', barcode)])
workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
if workorder_old:
raise UserError('该托盘已绑定【%s】制造订单,请先解除绑定!!!' % workorder_old.production_id.name)
if workorder:
if workorder.routing_type == '装夹预调':
if workorder.state in ['done']:
@@ -1086,12 +1082,11 @@ class WorkPieceDelivery(models.Model):
delivery_num = fields.Char('工件配送编码')
workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
production_id = fields.Many2one('mrp.production', string='制造订单', readonly=True)
production_id = fields.Many2one('mrp.production', string='制造订单', readonly=True)
production_line_id = fields.Many2one('sf.production.line', compute='_compute_production_line_id',
string='目的生产线', readonly=True,
store=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True)
sametransport_production_ids = fields.Many2many('mrp.production', 'rel_workpiece_production', string='同运工件编码')
route_id = fields.Many2one('sf.agv.task.route', '任务路线')
feeder_station_start_id = fields.Many2one('sf.agv.site', '起点接驳站')
@@ -1102,25 +1097,56 @@ class WorkPieceDelivery(models.Model):
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
status = fields.Selection(
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
default='下发')
production_line_state = fields.Selection(
[('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线')
cnc_program_down_state = fields.Selection([('待下发', '待下发'), ('已下发', '已下发')],
string='CNC程序下发状态', default='待下发')
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', )
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
@api.onchange('route_id')
def onchage_route(self):
def onchange_route(self):
if self.route_id:
self.feeder_station_start_id = self.route_id.start_site_id
self.feeder_station_destination_id = self.route_id.end_site_id
self.feeder_station_start_id = self.route_id.start_site_id.id
self.feeder_station_destination_id = self.route_id.end_site_id.id
# 工件配送
def button_delivery(self):
if self.cnc_program_down_state == '待下发':
if self.route_id:
if self.status == '待下发':
delivery_ids = []
is_cnc_down = 0
is_not_production_line = 0
is_not_route = 0
same_production_line_id = None
same_route_id = None
down_status = '待下发'
production_type = '上产线'
num = 0
for item in self:
num += 1
if num > 4:
raise UserError('仅限于配送1-4个制造订单请重新选择')
if item.route_id:
if same_route_id is None:
same_route_id = item.route_id.id
if item.route_id.id != same_route_id:
is_not_route += 1
else:
raise UserError('请选择【任务路线】再进行配送')
# if production_type != item.type:
# raise UserError('请选择类型为【上产线】的制造订单进行配送')
if down_status != item.status:
raise UserError('请选择状态为【待下发】的制造订单进行配送')
if same_production_line_id is None:
same_production_line_id = item.production_line_id.id
if item.production_line_id.id != same_production_line_id:
is_not_production_line += 1
if item.is_cnc_program_down is False:
is_cnc_down += 1
if is_cnc_down == 0 and is_not_production_line == 0 and is_not_route == 0:
delivery_ids.append(item.id)
if is_cnc_down >= 1:
raise UserError('您所选择制造订单的【CNC程序】暂未下发请在程序下发后再进行配送')
if is_not_production_line >= 1:
raise UserError('您所选择制造订单的【目的生产线】不一致,请重新确认')
if is_not_route >= 1:
raise UserError('您所选择制造订单的【任务路线】不一致,请重新确认')
if delivery_ids:
return {
'name': _('确认'),
'type': 'ir.actions.act_window',
@@ -1128,40 +1154,43 @@ class WorkPieceDelivery(models.Model):
'res_model': 'sf.workpiece.delivery.wizard',
'target': 'new',
'context': {
'default_delivery_id': self.id,
'default_delivery_ids': [(6, 0, delivery_ids)],
}}
else:
raise UserError('状态为【待下发】的工件记录可进行配送')
else:
raise UserError('请选择任务路线再进行配送')
else:
raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送"))
# 配送至avg小车
def _delivery_avg(self):
agv_site = self.env['sf.agv.site'].search([])
# if agv_site:
# agv_site.update_site_state()
if agv_site:
agv_site.update_site_state()
config = self.env['res.config.settings'].get_values()
positionCode_Arr = []
if self.feeder_station_start_id:
delivery_Arr = []
feeder_station_start = None
feeder_station_destination = None
for item in self:
if feeder_station_start is None:
feeder_station_start = item.feeder_station_start_id.name
if feeder_station_destination is None:
feeder_station_destination = item.feeder_station_destination_id.name
delivery_Arr.append(item.delivery_num)
delivery_str = ', '.join(map(str, delivery_Arr))
if feeder_station_start is not None:
positionCode_Arr.append({
'positionCode': self.feeder_station_start_id.name,
'positionCode': feeder_station_start,
'code': '00'
})
if self.feeder_station_destination_id:
if feeder_station_destination is not None:
positionCode_Arr.append({
'positionCode': self.feeder_station_destination_id.name,
'positionCode': feeder_station_destination,
'code': '00'
})
res = {'reqCode': self.delivery_num, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
res = {'reqCode': delivery_str, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'],
'positionCodePath': positionCode_Arr,
'podCode': '',
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
'data': ''}
try:
# config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask'
logging.info('AGV请求路径:%s' % config['agv_rcs_url'])
logging.info('AGV-json:%s' % res)
headers = {'Content-Type': 'application/json'}
@@ -1169,16 +1198,16 @@ class WorkPieceDelivery(models.Model):
ret = ret.json()
logging.info('config-ret:%s' % ret)
if ret['code'] == 0:
if self.delivery_num == ret['reqCode']:
if self.sametransport_production_ids:
for item in self.sametransport_production_ids:
sametransport_workpiece = self.search(
[('production_id', '=', item.id), ('type', '=', '上产线')])
if sametransport_workpiece:
sametransport_workpiece.write(
{'task_delivery_time': fields.Datetime.now(), 'status': '待配送'})
self.write(
{'task_delivery_time': fields.Datetime.now(), 'status': '待配送'})
req_codes = ret['reqCode'].split(',')
for delivery_item in self:
for req_code in req_codes:
if delivery_item.delivery_num == req_code.strip():
logging.info('delivery_num:%s' % delivery_item.delivery_num)
delivery_item.write({
'task_delivery_time': fields.Datetime.now(),
'status': '待配送'
})
delivery_item.workorder_id.write({'is_delivery': True})
else:
raise UserError(ret['message'])
except Exception as e:

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"
@@ -186,7 +191,6 @@
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="functional_fixture_type_id"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code" force_save="1" readonly="1" cache="True"
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
@@ -265,7 +269,7 @@
placeholder="如有预调程序信息请在此处输入....."/>
</group>
<group string="加工图纸">
<!-- 隐藏加工图纸字段名 -->
<!-- 隐藏加工图纸字段名 -->
<field name="processing_drawing" widget="pdf_viewer" string=""/>
</group>
</page>
@@ -429,14 +433,14 @@
<field name="workpiece_delivery_ids">
<tree editable="bottom">
<field name="production_id" invisible="1"/>
<field name="sametransport_production_ids" widget="many2many_tags"/>
<field name="route_id" options="{'no_create': True}"/>
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
<field name="cnc_program_down_state" readonly="1"/>
<field name="is_cnc_program_down" readonly="1"/>
<field name="production_line_id"/>
<field name="task_delivery_time" readonly="1"/>
<field name="task_completion_time" readonly="1"/>
<field name="status"/>
</tree>
</field>
</page>
@@ -532,7 +536,8 @@
<field name="is_ok"/>
<field name="processing_user_id"/>
<field name="inspection_user_id"/>
<field name="save_name" widget="CopyClipboardChar" attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
<field name="save_name" widget="CopyClipboardChar"
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
<label for="material_length" string="物料尺寸"/>
<div class="o_address_format">
<label for="material_length" string="长"/>
@@ -583,14 +588,14 @@
decoration-success="status == '已配送'"
decoration-warning="status == '待下发'"
decoration-danger="status == '待配送'"/>
<field name="production_id" string="工件编码"/>
<field name="sametransport_production_ids" widget="many2many_tags"/>
<field name="type" />
<field name="production_id"/>
<field name="type"/>
<!-- <field name="delivery_num" />-->
<field name="production_line_id" options="{'no_create': True}"/>
<field name="route_id" options="{'no_create': True}"/>
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
<field name="cnc_program_down_state" readonly="1"/>
<field name="is_cnc_program_down" readonly="1"/>
<field name="task_delivery_time" readonly="1"/>
<field name="task_completion_time" readonly="1"/>
<field name="delivery_duration" widget="float_time"/>
@@ -603,8 +608,10 @@
<field name="model">sf.workpiece.delivery</field>
<field name="arch" type="xml">
<search string="工件配送">
<!-- <filter string="待下发" name="status" domain="[('status', '=', '待下发')]"/>-->
<!-- <filter string="待配送" name="status" domain="[('status', '=', '待配送')]"/>-->
<!-- <filter string="已配送" name="status" domain="[('status', '=', '已配送')]"/>-->
<field name="production_id"/>
<field name="sametransport_production_ids" widget="many2many_tags"/>
<field name="feeder_station_start_id"/>
<field name="production_line_id"/>
<field name="task_delivery_time"/>
@@ -614,10 +621,8 @@
<field name="status"/>
<searchpanel>
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
<field name="type" icon="fa-building" enable_counters="1"/>
<field name="status" icon="fa-building" enable_counters="1"/>
<field name="production_line_state" icon="fa-building" enable_counters="1"/>
<field name="cnc_program_down_state" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
</field>
@@ -626,7 +631,10 @@
<record id="sf_workpiece_delivery_act" model="ir.actions.act_window">
<field name="name">工件配送</field>
<field name="res_model">sf.workpiece.delivery</field>
<!-- <field name="search_view_id" ref="sf_workpiece_delivery_search"/>-->
<!-- <field name="context">{'search_default_status':'待下发'}</field>-->
<field name="view_mode">tree,search</field>
<!-- <field name="domain">[('type','in',['上产线']),('status','in',['待下发'])]</field>-->
</record>
</odoo>

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

@@ -5,7 +5,7 @@
<field name="model">sf.workpiece.delivery.wizard</field>
<field name="arch" type="xml">
<form>
<field name="delivery_id" invisible="True"/>
<field name="delivery_ids" invisible="True"/>
<field name="workorder_id" invisible="True"/>
<div>是否确定配送?</div>
<footer>

View File

@@ -9,11 +9,11 @@ class WorkpieceDeliveryWizard(models.TransientModel):
_name = 'sf.workpiece.delivery.wizard'
_description = '工件配送'
delivery_id = fields.Many2one('sf.workpiece.delivery', string='配送')
delivery_ids = fields.Many2many('sf.workpiece.delivery', string='配送')
workorder_id = fields.Many2one('mrp.workorder', string='工单')
def confirm(self):
if self.workorder_id:
self.workorder_id.workpiece_delivery_ids._delivery_avg()
self.workorder_id.workpiece_delivery_ids[0]._delivery_avg()
else:
self.delivery_id._delivery_avg()
self.delivery_ids._delivery_avg()

View File

@@ -56,7 +56,8 @@ class sf_production_plan(models.Model):
# # 加工时长
# process_time = fields.Float(string='加工时长', digits=(16, 2))
# 实际加工时长、实际开始时间、实际结束时间
actual_process_time = fields.Float(string='实际加工时长(分钟)', digits=(16, 2), compute='_compute_actual_process_time')
actual_process_time = fields.Float(string='实际加工时长(分钟)', digits=(16, 2),
compute='_compute_actual_process_time')
actual_start_time = fields.Datetime(string='实际开始时间')
actual_end_time = fields.Datetime(string='实际结束时间')
shift = fields.Char(string='班次')
@@ -81,6 +82,9 @@ class sf_production_plan(models.Model):
def _compute_production_line_id(self):
for item in self:
item.sudo().production_id.production_line_id = item.production_line_id.id
item.sudo().production_id.workorder_ids.filtered(
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
{'production_line_id': item.production_line_id.id})
# item.sudo().production_id.plan_start_processing_time = item.date_planned_start
# @api.onchange('state')

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,8 +63,9 @@ 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'])])
time = None

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

@@ -23,13 +23,13 @@
parent="menu_sf_tool_manage"
/>
<menuitem
sequence="10"
name="机床换刀申请"
id="menu_sf_machine_table_tool_changing_apply"
action="sf_machine_table_tool_changing_apply_view_act"
parent="menu_sf_function_tool_plan"
/>
<!-- <menuitem-->
<!-- sequence="10"-->
<!-- name="机床换刀申请"-->
<!-- id="menu_sf_machine_table_tool_changing_apply"-->
<!-- action="sf_machine_table_tool_changing_apply_view_act"-->
<!-- parent="menu_sf_function_tool_plan"-->
<!-- />-->
<menuitem
sequence="20"
name="CAM工单程序用刀计划"
@@ -42,7 +42,7 @@
<!-- ================功能菜单================= -->
<menuitem
sequence="5"
name="功能"
name="作业单"
id="menu_sf_function_tool_function"
parent="menu_sf_tool_manage"
/>

View File

@@ -12,10 +12,10 @@
<button string="获取机床刀库信息" name="register_equipment_tool" type="object" class="btn-primary"/>
<field name='product_template_ids'>
<tree editable='bottom'>
<field name="code" readonly="false"/>
<field name="code" readonly="1"/>
<field name="tool_code"/>
<field name="functional_tool_type"/>
<field name="functional_tool_name_id"/>
<field name="functional_tool_name_id" readonly="1"/>
<field name="image" widget="image"/>
<field name="tool_groups"/>
<field name="diameter"/>
@@ -23,7 +23,7 @@
<field name="life_value_max"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="tool_install_time"/>
<field name="tool_install_time" readonly="1"/>
</tree>
</field>
</page>

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'}

View File

@@ -1006,6 +1006,14 @@ class CustomStockMove(models.Model):
"""
for record in self:
if record:
lot = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
if lot:
if lot.product_id.cutting_tool_material_id:
material = lot.product_id.cutting_tool_material_id.name
else:
material = lot.product_id.fixture_material_id.name
raise ValidationError(
'该Rfid【%s】已经被序列号为【%s】的【%s】物料所占用!' % (barcode, lot.name, material))
if '刀柄' in (record.product_id.cutting_tool_material_id.name or '') or '托盘' in (
record.product_id.fixture_material_id.name or ''):
for move_line_nosuggest_id in record.move_line_nosuggest_ids: