From d1c10f56d1bea67dd82c69c3651efcc7e7de344b Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Fri, 5 Jan 2024 17:33:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1=E3=80=81sf=5Fbase=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E6=A8=A1=E5=9E=8B=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E6=89=80=E4=BB=A5=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=A8=A1=E5=9E=8B=E6=B7=BB=E5=8A=A0=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E5=AF=B9=E8=B1=A1=E5=AD=97=E6=AE=B5=EF=BC=88?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=B8=AD=EF=BC=89=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/tool_base_new.py | 9 +++++++++ sf_base/security/ir.model.access.csv | 1 + sf_base/views/tool_menu.xml | 7 +++++++ sf_base/views/tool_views.xml | 22 ++++++++++++++++++++++ sf_tool_management/models/base.py | 10 +++++++++- 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 4dc6b619..3d6504ab 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -238,3 +238,12 @@ class MaintenanceStandardImage(models.Model): else: record['image'] = "" return records + + +class ToolGroups(models.Model): + _name = 'sf.tool.groups' + _description = '刀具组' + + name = fields.Char('名称') + equipment_ids = fields.Many2many('maintenance.equipment', 'ref_maintenance_equipment', string='机台号') + remark = fields.Char('备注', size=50) diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 77c3e810..1490b9ef 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -28,6 +28,7 @@ access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,1,1, access_sf_international_standards,sf_international_standards,model_sf_international_standards,base.group_user,1,1,1,1 access_material_apply,material_apply,model_material_apply,base.group_user,1,1,1,1 access_sf_cutting_tool_standard_library,sf_cutting_tool_standard_library,model_sf_cutting_tool_standard_library,base.group_user,1,1,1,1 +access_sf_tool_groups,sf_tool_groups,model_sf_tool_groups,base.group_user,1,1,1,1 access_sf_tool_materials_basic_parameters,sf_tool_materials_basic_parameters,model_sf_tool_materials_basic_parameters,base.group_user,1,1,1,1 access_sf_cutting_speed,sf_cutting_speed,model_sf_cutting_speed,base.group_user,1,1,1,1 access_sf_feed_per_tooth,sf_feed_per_tooth,model_sf_feed_per_tooth,base.group_user,1,1,1,1 diff --git a/sf_base/views/tool_menu.xml b/sf_base/views/tool_menu.xml index cddb7d90..82ecca18 100644 --- a/sf_base/views/tool_menu.xml +++ b/sf_base/views/tool_menu.xml @@ -92,5 +92,12 @@ action="action_maintenance_equipment_image" sequence="5"/> + + diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index f189017d..d300f845 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -493,6 +493,28 @@ [] + + + 刀具组 + sf.tool.groups + + + + + + + + + + + + + 刀具组 + ir.actions.act_window + sf.tool.groups + tree,form,search + + diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 80ac3811..d64b8ee1 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -10,7 +10,8 @@ class FunctionalCuttingToolEntity(models.Model): _name = 'sf.functional.cutting.tool.entity' _description = '功能刀具列表' - # code = fields.Char('序列号') + code = fields.Char('编码', related='functional_tool_name_id.code') + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id') name = fields.Char(related='functional_tool_name_id.name') functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) @@ -175,6 +176,8 @@ class FunctionalToolWarning(models.Model): _name = 'sf.functional.tool.warning' _description = '功能刀具预警' + code = fields.Char('编码', related='functional_tool_name_id.code') + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id') name = fields.Char('名称', invisible=True, readonly=True, related='functional_tool_name_id.name') # 机床信息 production_line_id = fields.Many2one('sf.production.line', string='生产线', @@ -243,6 +246,8 @@ class StockMoveLine(models.Model): diameter = fields.Integer(string='刀具直径(mm)', related='functional_tool_name_id.functional_tool_diameter') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle') install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time') + code = fields.Char('编码', related='functional_tool_name_id.code') + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id') @api.model def _read_group_functional_tool_type_id(self, categories, domain, order): @@ -255,6 +260,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model): _description = '功能刀具安全库存' name = fields.Char('功能刀具名称', readonly=False) + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组') sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False, group_expand='_read_mrs_cutting_tool_type_ids', store=True) diameter = fields.Integer(string='刀具直径(mm)', readonly=False) @@ -421,6 +427,8 @@ class MachineTableToolChangingApply(models.Model): cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True, required=True, domain="[('equipment_id', '=', maintenance_equipment_id)]") # 功能刀具信息 + code = fields.Char('编码', related='functional_tool_name_id.code') + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id') functional_tool_name = fields.Char(string='刀具名称', related='functional_tool_name_id.name', store=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', store=True, domain=[('product_id.name', '=', '功能刀具')], From 498e1c12afb6e03ffaec9f6a30d50fc0aaf8a0a0 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 8 Jan 2024 17:42:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1=E3=80=81=E6=89=80=E6=9C=89=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=9B=B8=E5=85=B3=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=80=E5=85=B7=E7=BB=84=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0=E6=A0=B9=E6=8D=AE=E8=A7=84?= =?UTF-8?q?=E5=88=99=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85?= =?UTF-8?q?=E6=97=B6=E6=8C=89=E8=A7=84=E5=88=99=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BC=96=E7=A0=81?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 79 +++++++++++++------- sf_tool_management/models/base.py | 19 ++++- sf_tool_management/views/tool_base_views.xml | 38 ++++++++-- sf_tool_management/wizard/wizard.py | 78 ++++++++++++++++++- sf_tool_management/wizard/wizard_view.xml | 8 +- 5 files changed, 179 insertions(+), 43 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 333da9aa..b974dba4 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -486,6 +486,8 @@ class ResProductMo(models.Model): string='适用刀柄型号' ) + + # 注册状态 register_state = fields.Selection([('未注册', '未注册'), ('已注册', '已注册'), ('注册失败', '注册失败')], string='注册状态', default='未注册') @@ -598,35 +600,35 @@ class ResProductMo(models.Model): if item.fixture_material_id.id != item.fixture_model_id.fixture_material_id.id: item.fixture_model_id = False - @api.onchange('fixture_model_id') - def _onchange_fixture_model_id(self): - for item in self: - if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']: - item.brand_id = item.fixture_model_id.brand_id.id - item.fixture_multi_mounting_type_id = item.fixture_model_id.multi_mounting_type_id.id - item.fixture_model_file = item.fixture_model_id.model_file - item.tool_length = item.fixture_model_id.length - item.tool_width = item.fixture_model_id.width - item.tool_height = item.fixture_model_id.height - item.tool_weight = item.fixture_model_id.weight - item.materials_type_id = item.fixture_model_id.materials_model_id.id - item.fixture_maximum_carrying_weight = item.fixture_model_id.maximum_carrying_weight - item.fixture_maximum_clamping_force = item.fixture_model_id.maximum_clamping_force - if self.fixture_material_type in ['零点卡盘', '转接板(锁板)夹具']: - item.fixture_clamping_way = item.fixture_model_id.clamping_way - item.fixture_port_type = item.fixture_model_id.port_type - if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具']: - item.fixture_driving_way = item.fixture_model_id.driving_way - if self.fixture_material_type in ['气动夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']: - item.fixture_through_hole_size = item.fixture_model_id.through_hole_size - item.fixture_screw_size = item.fixture_model_id.screw_size - if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具']: - item.fixture_clamp_workpiece_length_max = item.fixture_model_id.clamp_workpiece_length_max - item.fixture_clamp_workpiece_width_max = item.fixture_model_id.clamp_workpiece_width_max - item.fixture_clamp_workpiece_height_max = item.fixture_model_id.clamp_workpiece_height_max - item.fixture_clamp_workpiece_diameter_max = item.fixture_model_id.clamp_workpiece_diameter_max - item.fixture_apply_machine_tool_type_ids = self._get_ids( - item.fixture_model_id.apply_machine_tool_type_ids) + # @api.onchange('fixture_model_id') + # def _onchange_fixture_model_id(self): + # for item in self: + # if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']: + # item.brand_id = item.fixture_model_id.brand_id.id + # item.fixture_multi_mounting_type_id = item.fixture_model_id.multi_mounting_type_id.id + # item.fixture_model_file = item.fixture_model_id.model_file + # item.tool_length = item.fixture_model_id.length + # item.tool_width = item.fixture_model_id.width + # item.tool_height = item.fixture_model_id.height + # item.tool_weight = item.fixture_model_id.weight + # item.materials_type_id = item.fixture_model_id.materials_model_id.id + # item.fixture_maximum_carrying_weight = item.fixture_model_id.maximum_carrying_weight + # item.fixture_maximum_clamping_force = item.fixture_model_id.maximum_clamping_force + # if self.fixture_material_type in ['零点卡盘', '转接板(锁板)夹具']: + # item.fixture_clamping_way = item.fixture_model_id.clamping_way + # item.fixture_port_type = item.fixture_model_id.port_type + # if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具']: + # item.fixture_driving_way = item.fixture_model_id.driving_way + # if self.fixture_material_type in ['气动夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']: + # item.fixture_through_hole_size = item.fixture_model_id.through_hole_size + # item.fixture_screw_size = item.fixture_model_id.screw_size + # if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具']: + # item.fixture_clamp_workpiece_length_max = item.fixture_model_id.clamp_workpiece_length_max + # item.fixture_clamp_workpiece_width_max = item.fixture_model_id.clamp_workpiece_width_max + # item.fixture_clamp_workpiece_height_max = item.fixture_model_id.clamp_workpiece_height_max + # item.fixture_clamp_workpiece_diameter_max = item.fixture_model_id.clamp_workpiece_diameter_max + # item.fixture_apply_machine_tool_type_ids = self._get_ids( + # item.fixture_model_id.apply_machine_tool_type_ids) def _get_volume_uom_id_from_ir_config_parameter(self): product_length_in_feet_param = self.env['ir.config_parameter'].sudo().get_param('product.volume_in_cubic_feet') @@ -877,6 +879,25 @@ class ResProductFixture(models.Model): mounting_hole_depth = fields.Float('安装孔深度(mm)', digits=(16, 2)) centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2)) + # (待删除字段) + fixture_multi_mounting_type_id = fields.Many2one('sf.multi_mounting.type', string="联装类型") + fixture_clamping_way = fields.Char(string="装夹方式") + fixture_port_type = fields.Char(string="接口类型") + fixture_model_file = fields.Binary(string="3D模型图") + + fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度max(mm)") + fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度max(mm)") + fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度max(mm)") + fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径max(mm)", digits=(16, 6)) + + fixture_maximum_carrying_weight = fields.Float(string="最大承载重量(kg)", digits=(16, 4)) + fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)") + fixture_driving_way = fields.Char(string="驱动方式") + fixture_apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_product_machine_tool_type', + string="适用机床型号") + fixture_through_hole_size = fields.Integer(string="过孔大小(mm)") + fixture_screw_size = fields.Integer(string="螺牙大小(mm)") + @api.onchange('specification_fixture_id') def _onchange_specification_fixture_id(self): if self.specification_fixture_id: diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index d64b8ee1..01f46343 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -10,8 +10,8 @@ class FunctionalCuttingToolEntity(models.Model): _name = 'sf.functional.cutting.tool.entity' _description = '功能刀具列表' - code = fields.Char('编码', related='functional_tool_name_id.code') tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id') + code = fields.Char('编码', related='functional_tool_name_id.code') name = fields.Char(related='functional_tool_name_id.name') functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) @@ -259,8 +259,8 @@ class RealTimeDistributionOfFunctionalTools(models.Model): _name = 'sf.real.time.distribution.of.functional.tools' _description = '功能刀具安全库存' - name = fields.Char('功能刀具名称', readonly=False) - tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组') + name = fields.Char('功能刀具名称', readonly=True, compute='_compute_name') + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=False, required=True) sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False, group_expand='_read_mrs_cutting_tool_type_ids', store=True) diameter = fields.Integer(string='刀具直径(mm)', readonly=False) @@ -303,6 +303,14 @@ class RealTimeDistributionOfFunctionalTools(models.Model): sf_functional_tool_assembly_ids = fields.Many2many('sf.functional.tool.assembly', 'sf_functional_tool_assembly_ref', '功能刀具组装单', readonly=True) + @api.depends('tool_groups_id', 'diameter', 'knife_tip_r_angle') + def _compute_name(self): + for obj in self: + if obj.tool_groups_id: + obj.name = '%s-D%sR%s' % (obj.tool_groups_id.name, obj.diameter, obj.knife_tip_r_angle) + else: + obj.name = None + @api.constrains('min_stock_num', 'max_stock_num') def _check_stock_num(self): for obj in self: @@ -347,6 +355,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model): functional_tool_assembly = tool.env['sf.functional.tool.assembly'].sudo().create({ 'functional_tool_name': tool.name, 'functional_tool_type_id': tool.sf_cutting_tool_type_id.id, + 'tool_groups_id': tool.tool_groups_id.id, 'functional_tool_diameter': tool.diameter, 'knife_tip_r_angle': tool.knife_tip_r_angle, 'coarse_middle_thin': tool.coarse_middle_thin, @@ -685,8 +694,10 @@ class FunctionalToolAssembly(models.Model): for obj in self: obj.name = obj.after_assembly_functional_tool_name + code = fields.Char('功能刀具编码', readonly=True) + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True) name = fields.Char(string='名称', readonly=True, compute='_compute_name') - assembly_order_code = fields.Char(string='编码', readonly=True) + assembly_order_code = fields.Char(string='组装单编码', readonly=True) functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True) functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 62c0f0eb..f357168d 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -10,6 +10,7 @@ + @@ -80,9 +81,11 @@ + + + @@ -310,7 +314,7 @@

- +

@@ -318,6 +322,8 @@ + + + @@ -513,6 +521,8 @@ name="%(sf_tool_management.sf_tool_change_requirement_information_act)d" type="action" context="{ 'default_name':name, + 'default_code':code, + 'default_tool_groups_id':tool_groups_id, 'default_production_line_id': production_line_id, 'default_maintenance_equipment_id': maintenance_equipment_id, 'default_machine_table_type_id': machine_table_type_id, @@ -548,6 +558,8 @@ name="%(sf_tool_management.sf_tool_transfer_request_information_act)d" type="action" context="{ 'default_name':name, + 'default_code':code, + 'default_tool_groups_id':tool_groups_id, 'default_production_line_id': production_line_id, 'default_maintenance_equipment_id': maintenance_equipment_id, 'default_machine_table_type_id': machine_table_type_id, @@ -587,6 +599,8 @@ name="%(sf_tool_management.sf_tool_change_requirement_information_act)d" type="action" context="{ 'default_name':name, + 'default_code':code, + 'default_tool_groups_id':tool_groups_id, 'default_production_line_id': production_line_id, 'default_maintenance_equipment_id': maintenance_equipment_id, 'default_machine_table_type_id': machine_table_type_id, @@ -673,9 +687,11 @@ + + @@ -856,7 +872,9 @@ + + @@ -878,7 +896,7 @@ - +