1.优化制造订单的检测结果:新增处理结果字段
2.优化制造订单的返工向导:加工面字段类型改为多对多,且该字段需根据处理结果为待处理的检测结果的加工面进行过滤 3.优化工单工件下产线接口:工单状态为待检测 4,.优化工单状态方法(_compute_state)
This commit is contained in:
@@ -16,62 +16,72 @@ class ReworkWizard(models.TransientModel):
|
||||
rework_reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
|
||||
("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
routing_type = fields.Selection([
|
||||
('装夹预调', '装夹预调'),
|
||||
('CNC加工', 'CNC加工')], string="工序类型")
|
||||
# 根据工单的加工面来显示
|
||||
processing_panel_id = fields.Many2one('sf.processing.panel', string="加工面")
|
||||
processing_panel_id = fields.Many2many('sf.processing.panel', string="加工面")
|
||||
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
|
||||
reprogramming_num = fields.Integer('重新编程次数', default=0)
|
||||
programming_state = fields.Selection(
|
||||
[('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发')], string='编程状态')
|
||||
|
||||
def confirm(self):
|
||||
if self.is_reprogramming is True:
|
||||
if self.production_id.workorder_ids:
|
||||
panel_workorder = self.production_id.workorder_ids.filtered(
|
||||
lambda ap: ap.processing_panel == self.processing_panel_id.name)
|
||||
if panel_workorder:
|
||||
panel_workorder.write({'state': 'rework'})
|
||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||
[('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
workorders_values = []
|
||||
for route in product_routing_workcenter:
|
||||
if route.is_repeat is True:
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str(self.processing_panel_id.name,
|
||||
self.production_id, route, False))
|
||||
if workorders_values:
|
||||
self.production_id.write(
|
||||
{'workorder_ids': workorders_values, 'programming_state': '编程中', 'work_state': '编程中',
|
||||
'reprogramming_num': self.production_id.reprogramming_num + 1})
|
||||
self.production_id._reset_work_order_sequence()
|
||||
self.production_id.update_programming_state()
|
||||
else:
|
||||
if self.routing_type in ['装夹预调', 'CNC加工']:
|
||||
self.workorder_id.is_rework = True
|
||||
self.production_id.write({'detection_result_ids': [(0, 0, {
|
||||
'rework_reason': self.rework_reason,
|
||||
'detailed_reason': self.detailed_reason,
|
||||
# 'processing_panel': self.workorder_id.processing_panel,
|
||||
'processing_panel': self.workorder_id.processing_panel,
|
||||
'routing_type': self.workorder_id.routing_type,
|
||||
'test_results': self.workorder_id.test_results,
|
||||
'handle_result': '待处理' if self.test_results == '返工' else '',
|
||||
'test_results': '返工' if not self.routing_type == 'CNC加工' else self.workorder_id.test_results,
|
||||
'test_report': self.workorder_id.detection_report})]})
|
||||
self.workorder_id.button_finish()
|
||||
else:
|
||||
if self.production_id.workorder_ids:
|
||||
for panel in self.processing_panel_id:
|
||||
panel_workorder = self.production_id.workorder_ids.filtered(
|
||||
lambda ap: ap.processing_panel == panel.name and ap.state != 'rework')
|
||||
if panel_workorder:
|
||||
panel_workorder.write({'state': 'rework'})
|
||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||
[('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
workorders_values = []
|
||||
for route in product_routing_workcenter:
|
||||
if route.is_repeat is True:
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str(panel.name,
|
||||
self.production_id, route, False))
|
||||
if workorders_values:
|
||||
self.production_id.write(
|
||||
{'workorder_ids': workorders_values, 'programming_state': '编程中', 'work_state': '编程中',
|
||||
'reprogramming_num': self.production_id.reprogramming_num + 1})
|
||||
self.production_id._reset_work_order_sequence()
|
||||
self.production_id.detection_result_ids.filtered(
|
||||
lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write(
|
||||
{'handle_result': '已处理'})
|
||||
if self.is_reprogramming is True:
|
||||
self.production_id.update_programming_state()
|
||||
else:
|
||||
self.production_id.do_update_program()
|
||||
|
||||
@api.onchange('product_id')
|
||||
@api.onchange('production_id')
|
||||
def onchange_processing_panel_id(self):
|
||||
for item in self:
|
||||
domain = [('id', '=', False)]
|
||||
product_id = item.product_id
|
||||
production_id = item.production_id
|
||||
if product_id:
|
||||
if self.env.user.has_group('sf_base.group_sf_order_user'):
|
||||
panel_ids = []
|
||||
for p in product_id.model_processing_panel.split(','):
|
||||
for p in production_id.detection_result_ids.filtered(
|
||||
lambda ap1: ap1.handle_result == '待处理'):
|
||||
panel = self.env['sf.processing.panel'].search(
|
||||
[('name', 'ilike', p)])
|
||||
[('name', 'ilike', p.processing_panel)])
|
||||
if panel:
|
||||
panel_ids.append(panel.id)
|
||||
domain = {'processing_panel_id': [('id', 'in', panel_ids)]}
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
<field name="production_id" invisible="True"/>
|
||||
<field name="workorder_id" invisible="True"/>
|
||||
<field name="product_id" invisible="True"/>
|
||||
<field name="routing_type" invisible="0"/>
|
||||
<group>
|
||||
<field name="processing_panel_id" options="{'no_create': True}"/>
|
||||
<field name="processing_panel_id" options="{'no_create': True}"
|
||||
attrs='{"invisible": [("routing_type","=","装夹预调")]}' widget="many2many_tags"/>
|
||||
</group>
|
||||
|
||||
<div>
|
||||
<div attrs='{"invisible": [("reprogramming_num","=",0)]}'>
|
||||
注意*: 该制造订单的产品已重复编程过<field name="reprogramming_num" string=""
|
||||
readonly="1"
|
||||
style='color:red;'/>次,且当前编程状态为
|
||||
@@ -24,11 +25,11 @@
|
||||
</div>
|
||||
<group>
|
||||
<field name="is_reprogramming"
|
||||
attrs='{"invisible": [("is_reprogramming","=",False)],"readonly": [("programming_state","in",["编程中","已编程未下发时"])]}'/>
|
||||
attrs='{"invisible": [("programming_state","=",False)],"readonly": [("programming_state","in",["编程中","已编程未下发时"])]}'/>
|
||||
<field name="rework_reason"
|
||||
attrs='{"invisible": [("is_reprogramming","=",True)],"required": [("is_reprogramming","=",False)]}'/>
|
||||
attrs='{"invisible": [("routing_type","!=","")],"required": [("routing_type","in",["装夹预调"])]}'/>
|
||||
<field name="detailed_reason"
|
||||
attrs='{"invisible": [("is_reprogramming","=",True)],"required": [("is_reprogramming","=",False)]}'/>
|
||||
attrs='{"invisible": [("routing_type","!=","")],"required": [("routing_type","in",["装夹预调"])]}'/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认返工"/>
|
||||
|
||||
Reference in New Issue
Block a user