优化返工和报废
This commit is contained in:
@@ -199,7 +199,12 @@ class ResMrpWorkOrder(models.Model):
|
||||
production_line_state = fields.Selection(related='production_id.production_line_state',
|
||||
string='上/下产线', store=True)
|
||||
detection_report = fields.Binary('检测报告', readonly=True)
|
||||
is_remanufacture = fields.Boolean(string='是否重新生成制造订单', default=True)
|
||||
is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False)
|
||||
is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False)
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因")
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
|
||||
@api.onchange('rfid_code')
|
||||
def _onchange(self):
|
||||
@@ -672,14 +677,14 @@ class ResMrpWorkOrder(models.Model):
|
||||
"""
|
||||
重新生成制造订单或者重新生成工单
|
||||
"""
|
||||
if self.test_results == '报废':
|
||||
if self.test_results in ['返工', '报废']:
|
||||
values = self.env['mrp.production'].create_production1_values(self.production_id)
|
||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
||||
self.production_id.company_id).create(
|
||||
values)
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
productions._create_workorder()
|
||||
productions._create_workorder(is_fetchcnc=self.is_fetchcnc, scrap_production=self.production_id)
|
||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||
(
|
||||
p.move_dest_ids.procure_method != 'make_to_order' and
|
||||
@@ -772,13 +777,13 @@ class ResMrpWorkOrder(models.Model):
|
||||
'product_id': productions.product_id.id,
|
||||
'state': 'draft',
|
||||
})
|
||||
if self.test_results == '返工':
|
||||
productions = self.production_id
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
productions._create_workorder2(self.processing_panel)
|
||||
else:
|
||||
self.results = '合格'
|
||||
# if self.test_results == '返工':
|
||||
# productions = self.production_id
|
||||
# # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# # self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
# productions._create_workorder2(self.processing_panel)
|
||||
# else:
|
||||
# self.results = '合格'
|
||||
|
||||
def json_workorder_str1(self, k, production, route):
|
||||
workorders_values_str = [0, '', {
|
||||
@@ -807,24 +812,23 @@ class ResMrpWorkOrder(models.Model):
|
||||
def _compute_state(self):
|
||||
super(ResMrpWorkOrder, self)._compute_state()
|
||||
for item in self:
|
||||
scrap_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
|
||||
('state', '=', 'done'), ('is_remanufacture', '=', True)])
|
||||
print(item.name)
|
||||
print(item.state)
|
||||
if item.name == 'CNC加工(返工)' and item.state not in ['ready', 'progress', 'done']:
|
||||
item.state = 'ready'
|
||||
print(item.is_remanufacture)
|
||||
scrap_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
|
||||
('state', '=', 'done'), ('test_results', 'in', ['返工', '报废'])])
|
||||
print(scrap_workorder)
|
||||
# if item.routing_type == 'CNC加工' and item.state in ['done'] and item.test_results in ['返工', '报废']:
|
||||
if item.routing_type == '解除装夹':
|
||||
last_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', item.production_id.id), ('name', '=', 'CNC加工(返工)'),
|
||||
('state', '!=', 'done')])
|
||||
if item.state != 'pending':
|
||||
if last_workorder:
|
||||
item.state = 'pending'
|
||||
if scrap_workorder:
|
||||
item.state = 'cancel'
|
||||
if scrap_workorder and item.state not in ['cancel']:
|
||||
item.state = 'cancel'
|
||||
elif item.routing_type == '表面工艺':
|
||||
if scrap_workorder:
|
||||
stock_move = self.env['stock.move'].search(
|
||||
[('origin', '=', item.production_id.name)])
|
||||
stock_move.write({'state': 'cancel'})
|
||||
item.picking_ids.write({'state': 'cancel'})
|
||||
item.state = 'cancel'
|
||||
|
||||
# 重写工单开始按钮方法
|
||||
@@ -991,7 +995,10 @@ class ResMrpWorkOrder(models.Model):
|
||||
'date_planned_finished': tem_date_planned_finished # 保持原值
|
||||
})
|
||||
if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
|
||||
record.recreateManufacturingOrWorkerOrder()
|
||||
record.production_id.write({'state': 'cancel'})
|
||||
record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})
|
||||
if record.is_remanufacture is True:
|
||||
record.recreateManufacturingOrWorkerOrder()
|
||||
is_production_id = True
|
||||
for workorder in record.production_id.workorder_ids:
|
||||
if workorder.state != 'done':
|
||||
|
||||
Reference in New Issue
Block a user