From 93c3548b4068cfae0e2d498e59bfbd9fbd79e8f5 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 3 Jul 2024 11:05:55 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=B3=A8=E9=87=8AOCC=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/__manifest__.py | 2 +- sf_manufacturing/models/product_template.py | 4 ++-- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 54538a7d..0447eb16 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -19,7 +19,7 @@ 'wizard/workpiece_delivery_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/product_template.py b/sf_manufacturing/models/product_template.py index 4d05de81..f292d694 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -7,8 +7,8 @@ import os from odoo import models, fields, api, _ from odoo.exceptions import ValidationError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index e3bf3002..11acc06f 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 3ae65db3..92f6cda2 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # from OCC.Core.GProp import GProp_GProps -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path From a7a8e7361685c8c9355d4619c9d441af0954df0d Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 3 Jul 2024 17:35:29 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BF=94=E5=B7=A5?= =?UTF-8?q?=E5=90=91=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/__manifest__.py | 3 +- sf_manufacturing/models/mrp_production.py | 35 ++++++++++++++++++- sf_manufacturing/models/mrp_workorder.py | 19 ++++++++-- sf_manufacturing/security/ir.model.access.csv | 3 ++ .../views/mrp_production_addional_change.xml | 23 ++++++++++-- sf_manufacturing/views/mrp_workorder_view.xml | 8 ++--- sf_manufacturing/wizard/__init__.py | 1 + sf_manufacturing/wizard/rework_wizard.py | 30 ++++++++++++++++ .../wizard/rework_wizard_views.xml | 31 ++++++++++++++++ 9 files changed, 142 insertions(+), 11 deletions(-) create mode 100644 sf_manufacturing/wizard/rework_wizard.py create mode 100644 sf_manufacturing/wizard/rework_wizard_views.xml 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 @@