From 6caae0325a5cc96b208caae9ed1a0832ee70b0cf Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Tue, 20 Jun 2023 16:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E8=AE=A1?= =?UTF-8?q?=E5=88=92=EF=BC=88=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=92=8C?= =?UTF-8?q?CAM=E5=B7=A5=E5=8D=95=E7=A8=8B=E5=BA=8F=E7=94=A8=E5=88=80?= =?UTF-8?q?=E8=AE=A1=E5=88=92=EF=BC=89=E8=A7=86=E5=9B=BE=E5=B7=B2=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 101 +++++++++++++++++- .../security/ir.model.access.csv | 2 + sf_tool_management/views/menu_view.xml | 23 ++++ sf_tool_management/views/tool_base_views.xml | 85 ++++++++++++++- 4 files changed, 208 insertions(+), 3 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index ae13cb56..8932b3a3 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -26,7 +26,7 @@ class FunctionalCuttingToolEntity(models.Model): remark = fields.Char('备注') # 功能刀具出入库记录 特有字段 - thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '细')], string='粗/中/细') + thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '精')], string='粗/中/精') max_life_span = fields.Char(string='最大寿命值') # alarm_value = fields.Char(string='报警值') # used_value = fields.Char(string='已使用值') @@ -56,7 +56,8 @@ class FunctionalCuttingToolEntity(models.Model): return_processing_num = fields.Text(string='归还需磨削数量') return_total = fields.Text(string='合计') total = fields.Text(string='总计') - # remark = fields.Text(string='备注/说明') + + # remark = fields.Char(string='备注/说明') # @api.onchange('functional_cutting_tool_id') # def get_functional_cutting_tool_info(self): @@ -97,3 +98,99 @@ class FunctionalCuttingToolEntity(models.Model): else: new_code = '001' return new_code + + +class MachineTableToolChangingApply(models.Model): + _name = 'sf.machine.table.tool.changing.apply' + _description = '机床换刀申请' + + CNC_machine_table = fields.Char(string='CNC机床') + # todo 机床类型和刀位号 为 Many2one + machine_table_type = fields.Char(string='机床类型') + cutter_spacing_code = fields.Char(string='刀位号') + functional_tool_code = fields.Char(string='功能刀具编码') + functional_tool_name = fields.Char(string='功能刀具名称') + # todo 功能刀具类型为 Many2one + functional_tool_type = fields.Char(string='功能刀具类型') + diameter = fields.Char(string='直径') + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精') + hilt_name = fields.Char(string='刀柄名称') + hilt_code = fields.Char(string='刀柄编号') + max_lifetime_value = fields.Char(string='最大寿命值') + alarm_value = fields.Char(string='报警值') + used_value = fields.Char(string='已使用值') + functional_tool_status = fields.Selection([("0", "正常"), ('1', '异常')], string='功能刀具状态') + + replacement_tool_code = fields.Char(string='待换刀具编码') + replacement_tool_name = fields.Char(string='待换刀具名称') + replacement_tool_type = fields.Char(string='待换刀具类型') + replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], + string='粗/中/精') + new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧') + applicant = fields.Char(string='申请人') + used_tool_time = fields.Datetime(string='用刀时间') + reason_for_applying = fields.Char(string='申请原因') + remark = fields.Char(string='备注说明') + + def sync_tool_entity_from_tool_changing_apply_table(self): + """ + ‘功能刀具预警’数据同步到‘机床换刀申请’ + """ + # 获取源表中的所有记录 + source_records = self.env['sf.functional.cutting.tool.entity'].search([]) + + # 循环遍历每个记录 + for source_record in source_records: + # 检查目标表中是否存在相同的记录 + destination_record = self.search([('CNC_machine_table', '=', source_record.machine_tool_code)]) + if destination_record: + # 如果目标表中已经存在相同的记录,则更新该记录 + # todo + destination_record.name = source_record.name + else: + # 如果目标表中不存在相同的记录,则创建一个新记录 + destination_record = self.create({ + # todo + # 'name': source_record.name, + }) + + # todo + def tool_changing_apply(self): + """ + 换刀申请(按键) + """ + + # todo + def transfer(self): + """ + 转移(按键) + """ + + +class CAMWorkOrderProgramKnifePlan(models.Model): + _name = 'sf.cam.work.order.program.knife.plan' + _description = 'CAM工单程序用刀计划' + + CAM_cutter_spacing_code = fields.Char(string='CAM刀位号') + functional_tool_code = fields.Char(string='功能刀具编码') + functional_tool_name = fields.Char(string='功能刀具名称') + functional_tool_type = fields.Char(string='功能刀具类型') + machine_table_name = fields.Char(string='机台名称') + diameter = fields.Char(string='直径(程式)') + tool_loading_length = fields.Char(string='装刀长') + clearance_length = fields.Char(string='避空长') + tool_included_angle = fields.Char(string='刀尖角(R角)') + L_D = fields.Char(string='L/D') + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精') + required_cutting_time = fields.Char(string='需要切割时间') + whether_standard_tool = fields.Boolean(string='是否标准刀') + need_knife_time = fields.Datetime(string='需要用刀时间') + applicant = fields.Char(string='申请人') + reason_for_applying = fields.Char(string='申请原因') + remark = fields.Char(string='备注说明') + + # todo + def tool_loading_apply(self): + """ + 装刀申请(按键) + """ diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index 3156f716..7b514b89 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -1,5 +1,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1 +access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,base.group_user,1,1,1,1 +access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,base.group_user,1,1,1,1 diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index 2abf6a11..b0fc131c 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -49,5 +49,28 @@ parent="menu_sf_tool_manage" /> + + + + + + \ No newline at end of file diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 962759f4..baeb0882 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -36,7 +36,7 @@ - + 功能刀具出入库记录 sf.functional.cutting.tool.entity @@ -142,5 +142,88 @@ + + + + CAM工单程序用刀计划 + sf.cam.work.order.program.knife.plan + + + + + + + + + + + + + + + + + + + +