1.优化制造订单的检测结果:新增处理结果字段

2.优化制造订单的返工向导:加工面字段类型改为多对多,且该字段需根据处理结果为待处理的检测结果的加工面进行过滤
3.优化工单工件下产线接口:工单状态为待检测
4,.优化工单状态方法(_compute_state)
This commit is contained in:
jinling.yang
2024-07-12 17:32:53 +08:00
parent 7152b54017
commit 7885794322
9 changed files with 130 additions and 93 deletions

View File

@@ -107,7 +107,8 @@ class MrpProduction(models.Model):
precision_rounding=production.product_uom_id.rounding) >= 0:
production.state = 'to_close'
elif any(
(wo.test_results == '返工' and wo.state == 'done') or wo.state == 'rework' for wo in
(wo.test_results == '返工' and wo.state == 'done') or wo.state == 'rework' or (
wo.is_rework is True and wo.state == 'done') for wo in
production.workorder_ids):
production.state = 'rework'
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
@@ -757,7 +758,8 @@ class MrpProduction(models.Model):
# 返工
def button_rework(self):
self._cron_get_programming_state()
if self.programming_state != '已编程':
self._cron_get_programming_state()
return {
'name': _('返工'),
'type': 'ir.actions.act_window',
@@ -767,7 +769,8 @@ class MrpProduction(models.Model):
'context': {
'default_production_id': self.id,
'default_product_id': self.product_id.id,
'default_programming_state': self.programming_state
'default_programming_state': self.programming_state,
'default_is_reprogramming': True if self.programming_state in ['已编程'] else False
}
}
@@ -870,12 +873,15 @@ class sf_detection_result(models.Model):
('CNC加工', 'CNC加工')], string="工序类型")
rework_reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("operate computer", "操机"),
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
("operate computer", "操机"),
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
detailed_reason = fields.Text('详细原因')
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")],
string="检测结果", tracking=True)
test_report = fields.Binary('检测报告', readonly=True)
handle_result = fields.Selection([("待处理", "待处理"), ("已处理", "已处理")], default='', string="处理结果",
tracking=True)
# 查看检测报告
def button_look_test_report(self):

View File

@@ -47,7 +47,7 @@ class ResMrpWorkOrder(models.Model):
('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型")
results = fields.Char('结果')
state = fields.Selection(selection_add=[('to be detected', "待检测"), ('rework', '返工')])
state = fields.Selection(selection_add=[('to be detected', "待检测"), ('rework', '返工')], tracking=True)
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@@ -433,6 +433,7 @@ class ResMrpWorkOrder(models.Model):
work.compensation_value_y = eval(self.material_center_point)[1]
# work.process_state = '待加工'
# self.sudo().production_id.process_state = '待加工'
# self.sudo().production_id.process_state = '待加工'
self.date_finished = datetime.now()
workorder.button_finish()
@@ -464,7 +465,6 @@ class ResMrpWorkOrder(models.Model):
raise UserError(_("该工单暂未完成,无法进行工件配送"))
def button_rework_pre(self):
# production_ids |= self.production_id
return {
'name': _('返工'),
'type': 'ir.actions.act_window',
@@ -473,7 +473,8 @@ class ResMrpWorkOrder(models.Model):
'target': 'new',
'context': {
'default_workorder_id': self.id,
'default_production_ids': [(6, 0, [self.production_id.id])],
'default_production_id': self.production_id.id,
'default_routing_type': self.routing_type
}}
# 拼接工单对象属性值
@@ -819,28 +820,45 @@ class ResMrpWorkOrder(models.Model):
}]
return workorders_values_str
# @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
# def _compute_state(self):
# for workorder in self:
# if any(
# (wo.test_results == '返工' and wo.state == 'done') or wo.state == 'rework' for wo in
# production.workorder_ids):
# production.state = 'rework'
# if workorder.state == 'pending':
# if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
# workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
# continue
# if workorder.state not in ('waiting', 'ready'):
# continue
# if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
# workorder.state = 'pending'
# continue
# if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
# continue
# if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
# workorder.state = 'ready'
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
# workorder.state = 'waiting'
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
def _compute_state(self):
super()._compute_state()
for workorder in self:
if workorder.routing_type == '装夹预调' and workorder.state not in ['done', 'cancel', 'progress', 'rework']:
re_work = self.env['mrp.workorder'].search(
[('routing_type', '=', '装夹预调'), ('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel), ('state', '=', 'rework')])
if re_work:
workorder.state = 'waiting'
elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress',
'rework']:
per_work = self.env['mrp.workorder'].search(
[('routing_type', '=', '装夹预调'), ('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel), ('is_rework', '=', True)])
if per_work:
workorder.state = 'waiting'
# if workorder.routing_type == 'CNC加工' and workorder.state == 'progress':
# workorder.state = 'to be detected'
# for workorder in self:
# if workorder.is_rework is True and workorder.state == 'done':
# cnc_work = self.env['mrp.workorder'].search([('routing_type','=','CNC加工'),('production_id','=',workorder.production_id.id)])
# if cnc_work:
# cnc_work.state = 'waiting'
# if workorder.state == 'pending':
# if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
# workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
# continue
# if workorder.state not in ('waiting', 'ready'):
# continue
# if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
# workorder.state = 'pending'
# continue
# if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
# continue
# if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
# workorder.state = 'ready'
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
# workorder.state = 'waiting'
# 重写工单开始按钮方法
def button_start(self):