From 740df7c99a383741a352c18241e7d80ecc3bc7cb Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 20 Mar 2023 17:37:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E9=9D=A2=E5=B7=A5?= =?UTF-8?q?=E8=89=BA=E5=A4=96=E5=8D=8F=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/common.py | 1 + sf_base/views/common_view.xml | 4 ++- sf_manufacturing/models/model_type.py | 31 +++++++++++++++++-- .../models/mrp_routing_workcenter.py | 9 ++++-- sf_manufacturing/models/mrp_workorder.py | 19 ++++-------- sf_manufacturing/security/ir.model.access.csv | 2 ++ sf_manufacturing/views/model_type_view.xml | 11 +++++++ 7 files changed, 58 insertions(+), 19 deletions(-) diff --git a/sf_base/models/common.py b/sf_base/models/common.py index a1c33521..01b66a4d 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -50,6 +50,7 @@ class MrsProductionProcess(models.Model): partner_process_ids = fields.Many2many('res.partner', 'process_ids', '加工工厂') active = fields.Boolean('有效', default=True) parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数') + gain_way = fields.Selection([("自加工", "自加工"), ("外协", "外协")], default="", string="获取方式") class MrsProcessingTechnology(models.Model): diff --git a/sf_base/views/common_view.xml b/sf_base/views/common_view.xml index be899852..1f5e2907 100644 --- a/sf_base/views/common_view.xml +++ b/sf_base/views/common_view.xml @@ -58,8 +58,8 @@ + - @@ -101,6 +101,8 @@ + + diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index 5428534d..2787d28e 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -11,6 +11,9 @@ class ModelType(models.Model): '成品工序模板') embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id', '胚料工序模板') + surface_technics_routing_tmpl_ids = fields.One2many('sf.surface_technics.model.type.routing.sort', + 'surface_technics_model_type_id', + '表面工艺工序模板') class ProductModelTypeRoutingSort(models.Model): @@ -26,7 +29,7 @@ class ProductModelTypeRoutingSort(models.Model): ('前置三元定位检测', '前置三元定位检测'), ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), - ('解除装夹', '解除装夹'), ('切割', '切割') + ('解除装夹', '解除装夹'), ('切割', '切割'), ('绑定表面工艺', '绑定表面工艺') ], string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') product_model_type_id = fields.Many2one('sf.model.type') @@ -49,7 +52,7 @@ class EmbryoModelTypeRoutingSort(models.Model): ('前置三元定位检测', '前置三元定位检测'), ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), - ('解除装夹', '解除装夹'), ('切割', '切割') + ('解除装夹', '解除装夹'), ('切割', '切割'), ('绑定表面工艺', '绑定表面工艺') ], string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') embryo_model_type_id = fields.Many2one('sf.model.type') @@ -57,3 +60,27 @@ class EmbryoModelTypeRoutingSort(models.Model): _sql_constraints = [ ('route_model_type_uniq', 'unique (route_workcenter_id,embryo_model_type_id)', '胚料工序不能重复!') ] + + +class SurfaceTechnicsModelTypeRoutingSort(models.Model): + _name = 'sf.surface_technics.model.type.routing.sort' + _description = '表面工艺工序排序' + + sequence = fields.Integer('Sequence') + route_workcenter_id = fields.Many2one('mrp.routing.workcenter') + is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat') + routing_type = fields.Selection([ + ('获取CNC加工程序', '获取CNC加工程序'), + ('装夹', '装夹'), + ('前置三元定位检测', '前置三元定位检测'), + ('CNC加工', 'CNC加工'), + ('后置三元质量检测', '后置三元质量检测'), + ('解除装夹', '解除装夹'), ('切割', '切割'), ('绑定表面工艺', '绑定表面工艺') + ], string="工序类型", related='route_workcenter_id.routing_type') + workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') + surface_technics_model_type_id = fields.Many2one('sf.model.type') + + _sql_constraints = [ + ( + 'route_model_type_uniq', 'unique (route_workcenter_id,surface_technics_model_type_id)', '表面工艺工序不能重复!') + ] diff --git a/sf_manufacturing/models/mrp_routing_workcenter.py b/sf_manufacturing/models/mrp_routing_workcenter.py index 5bb08aa2..8eb22ca5 100644 --- a/sf_manufacturing/models/mrp_routing_workcenter.py +++ b/sf_manufacturing/models/mrp_routing_workcenter.py @@ -11,7 +11,8 @@ class ResMrpRoutingWorkcenter(models.Model): ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), - ('切割', '切割') + ('切割', '切割'), + ('绑定表面工艺', '绑定表面工艺') ], string="工序类型") is_repeat = fields.Boolean('重复', default=False) workcenter_id = fields.Many2one('mrp.workcenter', required=False) @@ -42,8 +43,10 @@ class ResMrpRoutingWorkcenter(models.Model): print(item.name) if item.machine_tool_id: machine_tool = self.env['sf.machine_tool'].search( - [('x_axis', '>', product.bom_ids.bom_line_ids.product_id.length), ('y_axis', '>', product.bom_ids.bom_line_ids.product_id.width), - ('z_axis', '>', product.bom_ids.bom_line_ids.product_id.height), ('id', '=', item.machine_tool_id.id)]) + [('x_axis', '>', product.bom_ids.bom_line_ids.product_id.length), + ('y_axis', '>', product.bom_ids.bom_line_ids.product_id.width), + ('z_axis', '>', product.bom_ids.bom_line_ids.product_id.height), + ('id', '=', item.machine_tool_id.id)]) if machine_tool: workcenter_ids.append(item.id) if len(workcenter_ids) == 1: diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 82e228a4..f858c88d 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -29,7 +29,7 @@ class ResMrpWorkOrder(models.Model): ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), - ('切割', '切割') + ('切割', '切割'), ('绑定表面工艺', '绑定表面工艺') ], string="工序类型") results = fields.Char('检测结果') @@ -137,7 +137,7 @@ class ResMrpWorkOrder(models.Model): except: raise UserError("参数计算有误") - #拼接工单对象属性值 + # 拼接工单对象属性值 def json_workorder_str(self, k, production, route): workorders_values_str = [0, '', { 'product_uom_id': production.product_uom_id.id, @@ -203,9 +203,9 @@ class ResMrpWorkOrder(models.Model): else: raise UserError('托盘码不能为空') - #验证坯料序列号是否正确 - def pro_code_is_ok(self,barcode): - if barcode!=False: + # 验证坯料序列号是否正确 + def pro_code_is_ok(self, barcode): + if barcode != False: if barcode != self.pro_code: raise UserError('坯料序列号错误') return False @@ -216,7 +216,7 @@ class ResMrpWorkOrder(models.Model): pro_code_ok = fields.Boolean(default=False) - #托盘扫码绑定 + # 托盘扫码绑定 def gettray_auto(self, barcode): if barcode != False: values = self.env['sf.tray'].search([("code", "=", barcode)]) @@ -255,7 +255,6 @@ class ResMrpWorkOrder(models.Model): else: raise UserError('托盘码不能为空') - # 解除托盘绑定 def unbindtray(self): tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)]) @@ -393,7 +392,6 @@ class ResMrpWorkOrder(models.Model): }] return workorders_values_str - # 重写工单开始按钮方法 def button_start(self): if self.routing_type == '装夹': @@ -467,7 +465,6 @@ class CNCprocessing(models.Model): workorder_id = fields.Many2one('mrp.workorder', string="工单") button_state = fields.Boolean(string='是否已经下发') - # mrs下发编程单创建CNC加工 def cnc_processing_create(self, cnc_workorder, ret): logging.info('ret:%s' % ret) @@ -567,8 +564,6 @@ class SfWorkOrderBarcodes(models.Model): else: self.pro_code_ok = workorder.pro_code_is_ok(barcode) - - # return { # 'type': 'ir.actions.act_window', # 'name': '工单', @@ -577,5 +572,3 @@ class SfWorkOrderBarcodes(models.Model): # 'context': {'active_id': self.id}, # # 'target': 'current', # } - - diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index f2bf5270..bc24436c 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -3,6 +3,8 @@ access_sf_cnc_processing,sf_cnc_processing,model_sf_cnc_processing,base.group_us access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1 access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,base.group_user,1,1,1,1 access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,base.group_user,1,1,1,1 +access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,base.group_user,1,1,1,1 + diff --git a/sf_manufacturing/views/model_type_view.xml b/sf_manufacturing/views/model_type_view.xml index e44f7311..e827e1df 100644 --- a/sf_manufacturing/views/model_type_view.xml +++ b/sf_manufacturing/views/model_type_view.xml @@ -55,6 +55,17 @@ + + + + + + + + + + +