This commit is contained in:
jinling.yang
2024-07-26 15:49:32 +08:00
6 changed files with 55 additions and 36 deletions

View File

@@ -532,9 +532,3 @@ div:has(.o_required_modifier) > label::before {
position: unset;
}
// 修改表格下拉框会被表格下面数据框覆盖的bug
.tab-pane .o_field_widget {
position: relative;
z-index: 1;
}

View File

@@ -29,41 +29,39 @@ class MrpProduction(models.Model):
detection_result_ids = fields.One2many('sf.detection.result', 'production_id', '检测报告')
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='功能刀具状态', default='0',
store=True, compute='_compute_tool_state')
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', readonly=True)
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True)
tool_state_remark2 = fields.Text(string='功能刀具状态备注(无效刀)', readonly=True)
@api.depends('workorder_ids.tool_state_remark')
def _compute_tool_state_remark(self):
for item in self:
if item.workorder_ids:
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工'))
if workorder_ids.filtered(lambda a: a.tool_state_remark):
work_ids = workorder_ids.filtered(lambda a: a.tool_state_remark)
tool_state_remark = ''
for work_id in work_ids:
tool_state_remark = f"{work_id.tool_state_remark}\n"
item.tool_state_remark = tool_state_remark
else:
item.tool_state_remark = False
@api.depends('workorder_ids.tool_state')
def _compute_tool_state(self):
# if self.workorder_ids:
for item in self:
if item.workorder_ids:
tool_state = item.tool_state
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工'))
if workorder_ids.filtered(lambda a: a.tool_state == '2'):
item.tool_state = '2'
elif workorder_ids.filtered(lambda a: a.tool_state == '1'):
tool_state_remark = ''
data = {}
# 获取所有缺刀工单加工面对应缺的刀
for work in workorder_ids.filtered(lambda a: a.tool_state == '1'):
if work.processing_panel not in list(data.keys()):
data.update({work.processing_panel: []})
for cnc in work.cnc_ids.filtered(lambda a: a.tool_state == '1'):
if cnc.cutting_tool_name not in data[work.processing_panel]:
data[work.processing_panel].append(cnc.cutting_tool_name)
# 按格式生成缺刀提示信息
for key in data:
if data.get(key) and not data.get(key):
if tool_state_remark != '':
tool_state_remark = f'{tool_state_remark}\n{key}缺刀:{data.get(key)}'
else:
tool_state_remark = f'{key}缺刀:{data.get(key)}'
item.tool_state = '1'
item.tool_state_remark = tool_state_remark
item.tool_state_remark2 = ''
else:
item.tool_state = '0'
item.tool_state_remark = ''
item.tool_state_remark2 = ''
if tool_state == '2' and item.tool_state != '2':
item.detection_result_ids.filtered(
lambda a: a.detailed_reason == '无效功能刀具' and a.handle_result == '待处理').write(
{'handle_result': '已处理'})
# state = fields.Selection(selection_add=[
# ('pending_scheduling', '待排程'),

View File

@@ -180,11 +180,27 @@ class ResMrpWorkOrder(models.Model):
# 功能刀具状态
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='功能刀具状态', default='0',
store=True, compute='_compute_tool_state')
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True)
@api.depends('cnc_ids.tool_state')
def _compute_tool_state_remark(self):
for item in self:
if item.cnc_ids:
if item.cnc_ids.filtered(lambda a: a.tool_state == '2'):
item.tool_state_remark = None
elif item.cnc_ids.filtered(lambda a: a.tool_state == '1'):
tool_state_remark = f'{item.processing_panel}缺刀:['
cnc_ids = item.cnc_ids.filtered(lambda a: a.tool_state == '1')
for cnc_id in cnc_ids:
tool_state_remark = f"{tool_state_remark}'{cnc_id.cutting_tool_name}'"
item.tool_state_remark = f"{tool_state_remark}]"
else:
item.tool_state_remark = None
@api.depends('cnc_ids.tool_state')
def _compute_tool_state(self):
for item in self:
if item:
if item.cnc_ids:
if item.cnc_ids.filtered(lambda a: a.tool_state == '2'):
item.tool_state = '2'
elif item.cnc_ids.filtered(lambda a: a.tool_state == '1'):
@@ -835,9 +851,10 @@ class ResMrpWorkOrder(models.Model):
# if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework'
if workorder.production_id.state == 'pending_cam':
if workorder.routing_type == '装夹预调' and workorder.state in ['ready', 'waiting']:
if workorder.production_id.tool_state in ['1', '2']:
workorder.state = 'waiting'
if workorder.production_id.tool_state in ['1', '2']:
work_ids = workorder.production_id.workorder_ids.filtered(
lambda a: a.routing_type == '装夹预调' and a.state in ['ready', 'waiting'])
work_ids.state = 'waiting'
logging.info('工序:%s' % workorder.sequence)
logging.info('工单最终状态:%s' % workorder.state)

View File

@@ -31,6 +31,8 @@ class ReworkWizard(models.TransientModel):
('已下发', '已下发')],
string='编程状态')
tool_state = fields.Selection(string='功能刀具状态', related='production_id.tool_state')
def confirm(self):
if self.routing_type in ['装夹预调', 'CNC加工']:
self.workorder_id.is_rework = True

View File

@@ -9,6 +9,7 @@
<field name="production_id" invisible="True"/>
<field name="workorder_id" invisible="True"/>
<field name="product_id" invisible="True"/>
<field name="tool_state" invisible="True"/>
<field name="routing_type" invisible="True"/>
<group>
<field name="processing_panel_id" options="{'no_create': True}"
@@ -25,15 +26,16 @@
decoration-warning="programming_state =='编程中'"
decoration-danger="programming_state =='已编程'" readonly="1"/>
</div>
<div attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","not in",["已下发"])]}'>
<div attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","not in",["已下发"])],"readonly": [("tool_state", "=", "2")]}'>
<span style='font-weight:bold;'>申请重新编程
<field name="is_reprogramming" force_save="1"/>
<field name="is_reprogramming" force_save="1"
attrs='{"readonly": [("tool_state", "=", "2")]}'/>
</span>
</div>
<div attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","in",["已下发"])],"readonly": [("is_reprogramming_readonly","=",False)]}'>
<div attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","in",["已下发"])],"readonly": ["|",("is_reprogramming_readonly","=",False),("tool_state", "=", "2")]}'>
<span style='font-weight:bold;'>申请重新编程
<field name="is_reprogramming_readonly"
attrs='{"readonly": [("is_reprogramming_readonly","=",False)]}'/>
attrs='{"readonly": ["|",("is_reprogramming_readonly","=",False),("tool_state", "=", "2")]}'/>
</span>
</div>
<group>

View File

@@ -105,6 +105,12 @@ class CNCprocessing(models.Model):
'test_results': '返工',
'handle_result': '待处理'
})
if not production_id.is_rework:
production_id.write({
'is_rework': True
})
production_id.workorder_ids.filtered(
lambda a: a.processing_panel == key and not a.is_rework).write({'is_rework': True})
# 对缺刀信息进行处理
for key in data2:
if data2.get(key):