diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 0447eb16..56b8514b 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -17,9 +17,10 @@ 'security/group_security.xml', 'security/ir.model.access.csv', 'wizard/workpiece_delivery_views.xml', + 'wizard/rework_wizard_views.xml', 'views/mrp_views_menus.xml', 'views/stock_lot_views.xml', - # 'views/mrp_production_addional_change.xml', + 'views/mrp_production_addional_change.xml', 'views/mrp_routing_workcenter_view.xml', 'views/production_line_view.xml', 'views/mrp_workcenter_views.xml', diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 73782a9c..30a0770e 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -24,6 +24,7 @@ class MrpProduction(models.Model): work_order_state = fields.Selection([('未排', '未排'), ('已排', '已排'), ('已完成', '已完成')], string='工单状态', default='未排') + detection_result_ids = fields.One2many('sf.detection.result', 'production_id', '检测报告') # state = fields.Selection(selection_add=[ # ('pending_scheduling', '待排程'), # ('pending_processing', '待加工'), @@ -34,9 +35,10 @@ class MrpProduction(models.Model): ('confirmed', '待排程'), ('pending_cam', '待加工'), ('progress', '加工中'), + ('rework', '返工'), ('to_close', 'To Close'), ('done', 'Done'), - ('cancel', 'Cancelled')], string='State', + ('cancel', '报废')], string='State', compute='_compute_state', copy=False, index=True, readonly=True, store=True, tracking=True, help=" * Draft: The MO is not confirmed yet.\n" @@ -683,3 +685,34 @@ class MrpProduction(models.Model): 'view_mode': 'tree,form', }) return action + + # 返工 + def button_rework(self): + return True + + # 报废 + def button_scrap_new(self): + return True + + # 更新程序 + def button_update_program(self): + return True + + +class sf_detection_result(models.Model): + _name = 'sf.detection.result' + _description = "检测结果" + + production_id = fields.Many2one('mrp.production') + processing_panel = fields.Char('加工面') + routing_type = fields.Selection([ + ('装夹预调', '装夹预调'), + ('CNC加工', 'CNC加工')], string="工序类型") + + rework_reason = fields.Selection( + [("programming", "编程"), ("cutter", "刀具"), ("operate computer", "操机"), + ("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True) + detailed_reason = fields.Text('详细原因') + test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格', + string="检测结果", tracking=True) + test_report = fields.Binary('检测报告', readonly=True) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 46bcde47..93d1b853 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -200,8 +200,8 @@ class ResMrpWorkOrder(models.Model): 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="原因", tracking=True) + [("programming", "编程"), ("cutter", "刀具"), ("operate computer", "操机"), + ("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True) detailed_reason = fields.Text('详细原因') # is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False) @@ -460,6 +460,21 @@ class ResMrpWorkOrder(models.Model): else: raise UserError(_("该工单暂未完成,无法进行工件配送")) + def button_rework_pre(self): + # production_ids |= self.production_id + return { + 'name': _('返工'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'sf.rework.wizard', + 'target': 'new', + 'context': { + 'default_workorder_id': self.id, + 'default_production_ids': [(6, 0, [self.production_id.id])], + }} + + + # 拼接工单对象属性值 def json_workorder_str(self, k, production, route, item): # 计算预计时长duration_expected diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index ec2d5a76..20a58086 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -141,3 +141,6 @@ access_sf_model_type_group_sf_stock_manager,sf_model_type_group_sf_mrp_manager,m access_mrp_bom_byproduct_group_sf_stock_user,mrp_bom_byproduct_group_sf_stock_user,mrp.model_mrp_bom_byproduct,sf_base.group_sf_stock_user,1,0,0,0 access_mrp_bom_byproduct_group_sf_stock_manager,mrp_bom_byproduct_group_sf_mrp_manager,mrp.model_mrp_bom_byproduct,sf_base.group_sf_stock_manager,1,0,0,0 +access_sf_rework_wizard_group_sf_order_user,sf_rework_wizard_group_sf_order_user,model_sf_rework_wizard,sf_base.group_sf_order_user,1,1,1,0 +access_sf_detection_result_group_sf_order_user,sf_detection_result_group_sf_order_user,model_sf_detection_result,sf_base.group_sf_order_user,1,1,1,0 + diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index b5e348b9..fef027a7 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -87,7 +87,7 @@ - + @@ -106,7 +106,14 @@