diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 68c7a0d7..3e155f78 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -77,6 +77,7 @@ class MrpProduction(models.Model): part_drawing = fields.Binary('零件图纸') manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) + rework_production = fields.Many2one('mrp.production', string='返工的制造订单') @api.depends( 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index b090d942..b0e31287 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -809,28 +809,28 @@ 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): - super(ResMrpWorkOrder, self)._compute_state() - for item in self: - print(item.name) - print(item.state) - 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 == '解除装夹': - 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' + # @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state') + # def _compute_state(self): + # super(ResMrpWorkOrder, self)._compute_state() + # for item in self: + # print(item.name) + # print(item.state) + # 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 == '解除装夹': + # 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' # 重写工单开始按钮方法 def button_start(self): @@ -987,6 +987,7 @@ class ResMrpWorkOrder(models.Model): raise UserError( '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name) tem_date_planned_finished = record.date_planned_finished + tem_date_finished = record.date_finished logging.info('routing_type:%s' % record.routing_type) super().button_finish() logging.info('date_planned_finished:%s' % record.date_planned_finished) @@ -995,6 +996,10 @@ class ResMrpWorkOrder(models.Model): record.write({ 'date_planned_finished': tem_date_planned_finished # 保持原值 }) + if record.routing_type == 'CNC加工': + record.write({ + 'date_finished': tem_date_finished # 保持原值 + }) if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']: record.production_id.action_cancel() record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})