diff --git a/jikimo_frontend/static/src/scss/custom_style.scss b/jikimo_frontend/static/src/scss/custom_style.scss index 00db5f3b..c01ca6c9 100644 --- a/jikimo_frontend/static/src/scss/custom_style.scss +++ b/jikimo_frontend/static/src/scss/custom_style.scss @@ -17,6 +17,7 @@ div:has(.o_required_modifier) > label::before { } .my-image div { + width: 110px !important; height: 110px !important; } @@ -261,7 +262,7 @@ div[class="o_content o_component_with_search_panel"] .o_kanban_primary_right > . .test_model > .o_form_label { margin-left: 4px !important; - line-height: 0 !important; + //line-height: 0 !important; } @media screen and (min-width: 1200px) { diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py index 6febb711..1fb1daa6 100644 --- a/sf_base/__manifest__.py +++ b/sf_base/__manifest__.py @@ -19,8 +19,9 @@ 'views/fixture_view.xml', 'views/functional_fixture_view.xml', 'views/menu_view.xml', - "views/tool_views.xml", - "views/tool_menu.xml", + 'views/tool_views.xml', + 'views/tool_basic_param.xml', + 'views/tool_menu.xml', 'views/menu_fixture_view.xml', ], diff --git a/sf_base/models/__init__.py b/sf_base/models/__init__.py index 483787eb..93961162 100644 --- a/sf_base/models/__init__.py +++ b/sf_base/models/__init__.py @@ -3,6 +3,7 @@ from . import common from . import tool_base_new from . import fixture from . import functional_fixture +from . import tool_other_features diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 81f4b4be..e781d10d 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -84,6 +84,7 @@ class MrsMaterialModel(models.Model): active = fields.Boolean('有效', default=True) + class MrsProductionProcessCategory(models.Model): _name = 'sf.production.process.category' _description = '表面工艺类别' diff --git a/sf_base/models/tool_base.py b/sf_base/models/tool_base.py deleted file mode 100644 index 24a39ecc..00000000 --- a/sf_base/models/tool_base.py +++ /dev/null @@ -1,304 +0,0 @@ -# -*- coding: utf-8 -*- -import logging - -from odoo import fields, models, api -# from odoo.exceptions import UserError -# # from odoo.addons import sf_base, sf_common -# from datetime import datetime - - -# 功能刀具物料 -class CuttingToolMaterial(models.Model): - _name = 'sf.cutting.tool.material' - _description = '刀具物料' - - code = fields.Char('编码') - name = fields.Char('名称') - remark = fields.Char('备注') - active = fields.Boolean('有效', default=True) - - -# 功能刀具 -class FunctionalCuttingTool(models.Model): - _name = 'sf.functional.cutting.tool' - _description = '功能刀具' - - code = fields.Char('编码') - name = fields.Char('名称') - functional_model_number = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - integral_model_number = fields.Many2one('sf.integral.cutting.tool', string='整体式刀具型号') - blade_model_number = fields.Many2one('sf.blade', string='刀片型号') - cutterbar_model_number = fields.Many2one('sf.cutter.bar', string='刀杆型号') - cutterpad_model_number = fields.Many2one('sf.cutter.pad', string='刀盘型号') - handle_model_number = fields.Many2one('sf.handle', string='刀柄型号') - chuck_model_number = fields.Many2one('sf.chuck', string='夹头型号') - diameter = fields.Float('直径(mm)') - tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级') - machining_accuracy = fields.Float('加工精度(mm)') - tool_length = fields.Float('装刀长') - blade_number = fields.Integer('刃数') - integral_blade_length = fields.Float('整体刃长(mm)') - effective_blade_length = fields.Float('有效刃长(mm)') - max_life = fields.Float('最大寿命值') - is_standard = fields.Boolean('是否标准刀') - applicable_range = fields.Char('适用范围') - image = fields.Binary('图片') - active = fields.Boolean('有效', default=True) - - -# 功能刀具类型 -class FunctionalCuttingToolModel(models.Model): - _name = 'sf.functional.cutting.tool.model' - _description = '功能刀具类型' - - name = fields.Char('名称') - code = fields.Char('编码') - remark = fields.Char('备注') - active = fields.Boolean('有效', default=True) - - -# 整体式刀具 -class IntegralCuttingTool(models.Model): - _name = 'sf.integral.cutting.tool' - _description = '整体式刀具' - - code = fields.Char('编码') - name = fields.Char('型号名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - # 整体式刀具类型字段,关联整体式刀具类型对象 - integral_model_number = fields.Many2one('sf.integral.cutting.tool.model', '整体式刀具类型') - # 增加品牌、总长度(mm)、柄部长度(mm)、刃部长度(mm)、直径(mm)、刃数、前角(°)、后角(°)、主偏角(°)、材料型号、配对螺母(mm)、适用夹头型号、适用范围、图片、创建人、创建时间等字段 - brand = fields.Many2one('sf.machine.brand', '品牌', domain="[('tag_ids.name', 'ilike', '刀具')]") - total_length = fields.Float('总长度(mm)') - shank_length = fields.Float('柄部长度(mm)') - blade_length = fields.Float('刃部长度(mm)') - diameter = fields.Float('直径(mm)') - blade_number = fields.Integer('刃数') - front_angle = fields.Float('前角(°)') - rear_angle = fields.Float('后角(°)') - main_included_angle = fields.Float('主偏角(°)') - material_model = fields.Many2one('sf.materials.model', '材料型号') - nut = fields.Float('配对螺母(mm)') - # 适用夹头型号可以多选 - chuck_model = fields.Many2many('sf.chuck', string='适用夹头型号') - scope = fields.Char('适用范围') - image = fields.Binary('图片') - active = fields.Boolean('有效', default=True) - - -# 整体式刀具类型 -class IntegralCuttingToolModel(models.Model): - _name = 'sf.integral.cutting.tool.model' - _description = '整体式刀具类型' - - code = fields.Char('编码') - name = fields.Char('名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - remark = fields.Char('备注') - - -# 刀片 -class Blade(models.Model): - _name = 'sf.blade' - _description = '刀片' - - code = fields.Char('编码') - name = fields.Char('型号名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - # 刀片类型字段,关联刀片类型对象 - blade_model_number = fields.Many2one('sf.blade.model', '刀片类型') - # 编码、型号名称、刀片类型、品牌、长度L(mm)、宽度D(mm)、高度T(mm)、顶角(°)、前角(°)、后角(°)、主偏角(°)、R角(°)、材料型号、加工硬度、配对螺母(mm)、适用刀杆/刀盘型号、刀尖半径(mm)、图片、创建人、创建时间字段 - brand = fields.Many2one('sf.machine.brand', '品牌', ) - length = fields.Float('长度L(mm)') - width = fields.Float('宽度D(mm)') - height = fields.Float('高度T(mm)') - top_angle = fields.Float('顶角(°)') - front_angle = fields.Float('前角(°)') - rear_angle = fields.Float('后角(°)') - main_included_angle = fields.Float('主偏角(°)') - r_angle = fields.Float('R角(°)') - material_model = fields.Many2one('sf.materials.model', '材料型号') - hardness = fields.Char('加工硬度') - nut = fields.Float('配对螺母(mm)') - # 适用刀杆型号可以多选 - cutter_bar = fields.Many2many('sf.cutter.bar', string='适用刀杆型号') - # 适用刀盘型号可以多选 - cutter_pad = fields.Many2many('sf.cutter.pad', string='适用刀盘型号') - radius = fields.Float('刀尖半径(mm)') - image = fields.Binary('图片') - - -# 刀片类型 -class BladeModel(models.Model): - _name = 'sf.blade.model' - _description = '刀片类型' - - code = fields.Char('编码') - name = fields.Char('名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - # 刀片类型字段,关联刀片对象 - blade_ids = fields.One2many('sf.blade', 'blade_model_number', '刀片类型') - remark = fields.Char('备注') - - -# 刀杆 -class CutterBar(models.Model): - _name = 'sf.cutter.bar' - _description = '刀杆' - - code = fields.Char('编码') - name = fields.Char('型号名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - # 刀杆类型字段,关联刀杆类型对象 - cutter_bar_model_number = fields.Many2one('sf.cutter.bar.model', '刀杆类型') - # 品牌、C柄径(mm)、L总长(mm)、材料型号、刃数、D刃径(mm)、适用刀片型号、配对扳手(mm)、配备螺丝(mm)、刀尖圆角半径、精度等级、硬度(°)、适用范围、图片、创建人、创建时间 - brand = fields.Many2one('sf.machine.brand', '品牌') - c_diameter = fields.Float('C柄径(mm)') - total_length = fields.Float('L总长(mm)') - material_model = fields.Many2one('sf.materials.model', '材料型号') - blade_number = fields.Integer('刃数') - d_diameter = fields.Float('D刃径(mm)') - blade = fields.Many2many('sf.blade', string='适用刀片型号') - wrench = fields.Float('配对扳手(mm)') - screw = fields.Float('配备螺丝(mm)') - radius = fields.Float('刀尖圆角半径') - accuracy = fields.Char('精度等级') - hardness = fields.Char('硬度(°)') - scope = fields.Char('适用范围') - image = fields.Binary('图片') - - -# 刀杆类型 -class CutterBarModel(models.Model): - _name = 'sf.cutter.bar.model' - _description = '刀杆类型' - - code = fields.Char('编码') - name = fields.Char('名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - remark = fields.Char('备注') - - -# 刀盘 -class CutterPad(models.Model): - _name = 'sf.cutter.pad' - _description = '刀盘' - - code = fields.Char('编码') - name = fields.Char('型号名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - # 刀盘类型字段,关联刀盘类型对象 - cutter_pad_model_number = fields.Many2one('sf.cutter.pad.model', '刀盘类型') - # 增加品牌、C柄径(mm)、L总长(mm)、材料型号、刃数、D刃径(mm)、适用刀片型号、配对扳手(mm)、配备螺丝(mm)、刀尖圆角半径、精度等级、硬度(°)、适用范围、图片、创建人、创建时间 - brand = fields.Many2one('sf.machine.brand', '品牌') - c_diameter = fields.Float('C柄径(mm)') - total_length = fields.Float('L总长(mm)') - material_model = fields.Many2one('sf.materials.model', '材料型号') - blade_number = fields.Integer('刃数') - d_diameter = fields.Float('D刃径(mm)') - blade = fields.Many2many('sf.blade', string='适用刀片型号') - wrench = fields.Float('配对扳手(mm)') - screw = fields.Float('配备螺丝(mm)') - radius = fields.Float('刀尖圆角半径') - accuracy = fields.Char('精度等级') - hardness = fields.Char('硬度(°)') - scope = fields.Char('适用范围') - image = fields.Binary('图片') - - -# 刀盘类型 -class CutterPadModel(models.Model): - _name = 'sf.cutter.pad.model' - _description = '刀盘类型' - - code = fields.Char('编码') - name = fields.Char('名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - remark = fields.Char('备注') - - -# 刀柄 -class Handle(models.Model): - _name = 'sf.handle' - _description = '刀柄' - - code = fields.Char('编码') - name = fields.Char('型号名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - # 刀柄类型字段,关联刀柄类型对象 - handle_model_number = fields.Many2one('sf.handle.model', '刀柄类型') - # 增加、刀柄类型、品牌、L(mm)、L1(mm)、D1(mm)、重量(kg)、材料型号、本体精度(mm)、配对螺母(mm)、适用夹头型号、夹持范围(mm)、检测精度、检测硬度、标准转速、图片、创建人、创建时间 - brand = fields.Many2one('sf.machine.brand', '品牌') - length = fields.Float('L(mm)') - length1 = fields.Float('L1(mm)') - diameter1 = fields.Float('D1(mm)') - weight = fields.Float('重量(kg)') - material_model = fields.Many2one('sf.materials.model', '材料型号') - body_accuracy = fields.Float('本体精度(mm)') - nut = fields.Float('配对螺母(mm)') - chuck_model = fields.Many2many('sf.chuck.model', string='适用夹头型号') - clamping_range = fields.Float('夹持范围(mm)') - detection_accuracy = fields.Float('检测精度') - detection_hardness = fields.Char('检测硬度') - standard_speed = fields.Float('标准转速') - image = fields.Binary('图片') - - -# 刀柄类型 -class HandleModel(models.Model): - _name = 'sf.handle.model' - _description = '刀柄类型' - - code = fields.Char('编码') - name = fields.Char('名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - remark = fields.Char('备注') - - -# 夹头对象(夹头型号对象) -class Chuck(models.Model): - _name = 'sf.chuck' - _description = '夹头' - _rec_name = 'code' - - code = fields.Char('编码') - name = fields.Char('型号名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - # 夹头类型字段,关联夹头类型对象 - chuck_model_number = fields.Many2one('sf.chuck.model', '夹头类型') - # 增加品牌、精度(mm)、外径(mm)、内径(mm)、高度(mm)、材料型号、配对螺母(mm)、适用刀柄型号、夹持范围(mm)、特性、图片、创建人、创建时间 - brand = fields.Many2one('sf.machine.brand', '品牌') - accuracy = fields.Float('精度(mm)') - diameter = fields.Float('外径(mm)') - inner_diameter = fields.Float('内径(mm)') - height = fields.Float('高度(mm)') - material_model = fields.Many2one('sf.materials.model', '材料型号') - nut = fields.Float('配对螺母(mm)') - handle_model = fields.Many2many('sf.handle.model', string='适用刀柄型号') - clamping_range = fields.Float('夹持范围(mm)') - feature = fields.Char('特性') - image = fields.Binary('图片') - - -# 夹头类型 -class ChuckModel(models.Model): - _name = 'sf.chuck.model' - _description = '夹头类型' - - code = fields.Char('编码') - name = fields.Char('名称') - # 关联刀具物料 - cutting_tool_material = fields.Many2one('sf.cutting.tool.material', '刀具物料') - remark = fields.Char('备注') diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index c957ab06..4d4c702a 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -26,7 +26,7 @@ class FunctionalCuttingTool(models.Model): name = fields.Char('名称') active = fields.Boolean('有效', default=True) mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号') + mrs_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号') # # 整体式刀具型号 # mrs_cutting_tool_integral_model_ids = fields.Many2many('sf.cutting.tool.model', 'rel_integral_model_functional_sf', @@ -91,133 +91,6 @@ class FunctionalCuttingToolModel(models.Model): active = fields.Boolean('有效', default=True) -# 刀具型号 -class CuttingToolModel(models.Model): - _name = 'sf.cutting.tool.model' - _description = '刀具型号' - - name = fields.Char('名称') - cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料') - cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True) - cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='刀具类型', - ) - brand_id = fields.Many2one('sf.machine.brand', '品牌', domain="[('tag_ids.name', 'ilike', '刀具')]") - tool_length = fields.Integer('长度(mm)') - tool_width = fields.Integer('宽度(mm)') - tool_height = fields.Integer('高度(mm)') - tool_thickness = fields.Integer('厚度(mm)') - tool_weight = fields.Float('重量(kg)') - coating_material = fields.Char('涂层材质') - - # 整体式刀具参数 - total_length = fields.Float('总长度(mm)') - shank_length = fields.Float('柄部长度(mm)') - blade_length = fields.Float('刃部长度(mm)') - diameter = fields.Float('直径(mm)') - blade_number = fields.Integer('刃数') - front_angle = fields.Float('前角(°)') - rear_angle = fields.Float('后角(°)') - main_included_angle = fields.Float('主偏角(°)') - material_model_id = fields.Many2one('sf.materials.model', '材料型号') - nut = fields.Float('配对螺母(mm)') - # 适用夹头型号可以多选 - chuck_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='cutting_tool_model_handle_chuck_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '夹头')]", - string='适用夹头型号') - # 刀片参数 - top_angle = fields.Float('顶角(°)') - jump_accuracy = fields.Float('径跳精度(um)') - working_hardness = fields.Char('加工硬度(hrc)') - cutter_bar_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='cutting_tool_model_blade_cutter_bar_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀杆')]", - string='适用刀杆型号' - ) - cutter_pad_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='cutting_tool_model_blade_cutter_pad_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀盘')]", - string='适用刀盘型号' # 使用空列表作为默认值 - ) - # 刀杆/参数 - blade_diameter = fields.Float('刃径(mm)') - blade_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='cutting_tool_model_pad_blade_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀片')]", - string='适用刀片型号' # 使用空列表作为默认值 - ) - wrench = fields.Float('配对扳手(mm)') - screw = fields.Float('配备螺丝(mm)') - accuracy_level = fields.Char('精度等级') - # 刀柄参数 - diameter_max = fields.Float('最大直径(mm)') - clamping_diameter = fields.Float('夹持直径(mm)') - flange_length = fields.Float('法兰柄长度(mm)') - flange_diameter = fields.Float('法兰直径(mm)') - # 夹头参数 - outer_diameter = fields.Float('外径(mm)') - inner_diameter = fields.Float('内径(mm)') - handle_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='cutting_tool_model_chuck_handle_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀柄')]", - string='适用刀柄型号' - ) - active = fields.Boolean('有效', default=True) - - def _get_code(self, cutting_tool_type_code): - cutting_tool_model = self.search( - [('code', 'ilike', cutting_tool_type_code)], - limit=1, - order="id desc") - if not cutting_tool_model: - num = "%03d" % 1 - else: - m = int(cutting_tool_model.code[-3:]) + 1 - num = "%03d" % m - return "%s%s" % (cutting_tool_type_code, num) - - code = fields.Char(string='编码', readonly=True) - - def _onchange_cutting_tool_material_id(self, cutting_tool_material_id): - if cutting_tool_material_id: - if cutting_tool_material_id.name == "整体式刀具": - code = self._get_code("JKM-T-DJWL-ZTDJ-") - elif cutting_tool_material_id.name == "刀片": - code = self._get_code("JKM-T-DJWL-DPIA-") - elif cutting_tool_material_id.name == "刀杆": - code = self._get_code("JKM-T-DJWL-DGAN-") - elif cutting_tool_material_id.name == "刀盘": - code = self._get_code("JKM-T-DJWL-DPAN-") - elif cutting_tool_material_id.name == "夹头": - code = self._get_code("JKM-T-DJWL-DJIA-") - else: - code = self._get_code("JKM-T-DJWL-DBIN-") - return code - - @api.model_create_multi - def create(self, vals): - obj = super(CuttingToolModel, self).create(vals) - if obj.cutting_tool_material_id: - code = self._onchange_cutting_tool_material_id(obj.cutting_tool_material_id) - obj.code = code - return obj - - # 刀具类型 class CuttingToolType(models.Model): _name = 'sf.cutting.tool.type' @@ -229,3 +102,175 @@ class CuttingToolType(models.Model): cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料') remark = fields.Char('备注') active = fields.Boolean('有效', default=True) + + +# 刀具标准库 +class CuttingToolModel(models.Model): + _name = 'sf.cutting_tool.standard.library' + _description = '刀具标准库' + + code = fields.Char(string='编码') + name = fields.Char('名称') + # 关联刀具物料 + cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料', required=True) + # 刀具物料类型 + cutting_tool_type = fields.Char(related='cutting_tool_material_id.name', string='刀具物料类型', + store=True) + # 关联刀具类型 + cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', '类型', + domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]") + brand_id = fields.Many2one('sf.machine.brand', '品牌') + status = fields.Boolean(string='状态', default=False) + image = fields.Binary('图片') + + # 整体式刀具参数 + material_model_id = fields.Many2one('mrs.materials.model', '刀具材质') + tool_hardness = fields.Integer('刀具硬度(hrc)') + coating_material = fields.Char('涂层材质') + blade_type = fields.Char('刃部类型') + integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '粗/中/精') + integral_run_out_accuracy_max = fields.Char('整体式刀具端跳精度max') + integral_run_out_accuracy_min = fields.Char('整体式刀具端跳精度min') + + fit_blade_shape_id = fields.Many2many('maintenance.equipment.image', 'fit_blade_shape_library_rel', + '适配刀片形状', domain=[('type', '=', '刀片形状')]) + suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image', + 'suitable_machining_method_library_rel', + '适合加工方式', domain=[('type', '=', '加工能力')]) + blade_tip_characteristics_id = fields.Many2many('maintenance.equipment.image', + 'blade_tip_character_library_rel', + '刀尖特征', domain=[('type', '=', '刀尖特征')]) + handle_type_ids = fields.Many2many('maintenance.equipment.image', 'handle_type_library_rel', + '柄部类型', domain=[('type', '=', '柄部类型')]) + cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'cutting_direction_library_rel', + '走刀方向', domain=[('type', '=', '走刀方向')]) + suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'suitable_coolant_library_rel', + '适合冷却液', domain=[('type', '=', '冷却液')]) + compaction_way_ids = fields.Many2many('maintenance.equipment.image', 'compaction_way_library_rel', + '压紧方式', domain=[('type', '=', '压紧方式')]) + integral_tool_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', + 'standard_library_id', string='整体式刀具基本参数') + blade_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', + 'standard_library_id', string='刀片基本参数') + cutter_bar_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', + 'standard_library_id', string='刀杆基本参数') + cutter_head_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', + 'standard_library_id', string='刀盘基本参数') + knife_handle_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', + 'standard_library_id', string='刀柄基本参数') + chuck_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', + 'standard_library_id', string='夹头基本参数') + cutting_speed_ids = fields.One2many('sf.cutting.speed', 'standard_library_id', string='切削速度Vc') + feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', + domain=[('cutting_speed', '!=', False)]) + feed_per_tooth_ids_2 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', + domain=[('machining_method', '!=', False)]) + feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', + domain=[('cutting_speed', '!=', False)]) + feed_per_tooth_ids_4 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', + domain=[('machining_method', '!=', False)]) + material_model_id = fields.Many2one('sf.materials.model', '材料型号') + # 适用夹头型号可以多选 + chuck_ids = fields.Many2many( + 'sf.cutting_tool.standard.library', + relation='cutting_tool_type_library_handle_chuck_rel', + column1='model_id_1', + column2='model_id_2', + domain="[('cutting_tool_material_id.name', '=', '夹头')]", + string='适用夹头型号') + cutter_bar_ids = fields.Many2many( + 'sf.cutting_tool.standard.library', + relation='cutting_tool_type_library_cutter_bar_rel', + column1='model_id_1', + column2='model_id_2', + domain="[('cutting_tool_material_id.name', '=', '刀杆')]", + string='适用刀杆型号' + ) + cutter_pad_ids = fields.Many2many( + 'sf.cutting_tool.standard.library', + relation='cutting_tool_type_library_cutter_pad_rel', + column1='model_id_1', + column2='model_id_2', + domain="[('cutting_tool_material_id.name', '=', '刀盘')]", + string='适用刀盘型号' # 使用空列表作为默认值 + ) + # 刀杆/参数 + blade_ids = fields.Many2many( + 'sf.cutting_tool.standard.library', + relation='cutting_tool_type_library_pad_blade_rel', + column1='model_id_1', + column2='model_id_2', + domain="[('cutting_tool_material_id.name', '=', '刀片')]", + string='适用刀片型号' # 使用空列表作为默认值 + ) + handle_ids = fields.Many2many( + 'sf.cutting_tool.standard.library', + relation='cutting_tool_type_library_chuck_handle_rel', + column1='model_id_1', + column2='model_id_2', + domain="[('cutting_tool_material_id.name', '=', '刀柄')]", + string='适用刀柄型号' + ) + active = fields.Boolean('有效', default=True) + is_cloud = fields.Boolean('云端数据', default=False) + + def _get_ids(self, cutting_tool_type_code, factory_short_name): + cutting_tool_type_ids = [] + for item in cutting_tool_type_code: + cutting_tool_type = self.search([('code', '=', item.replace("JKM", factory_short_name))]) + if cutting_tool_type: + cutting_tool_type_ids.append(cutting_tool_type.id) + return [(6, 0, cutting_tool_type_ids)] + + +class MaintenanceStandardImage(models.Model): + _name = 'maintenance.equipment.image' + _description = '能力特征库' + + active = fields.Boolean('有效', default=True) + name = fields.Char('名称') + image = fields.Binary(string='图文') + type = fields.Selection( + [('加工能力', '加工能力'), ('刀尖特征', '刀尖特征'), ('柄部类型', '柄部类型'), ('走刀方向', '走刀方向'), + ('冷却液', '冷却液'), ('压紧方式', '压紧方式'), ('刀片形状', '刀片形状')], + string='特征') + equipment_id = fields.Many2many('maintenance.equipment', 'image_id', string='设备') + + def _get_ids(self, name_arr): + ability_feature_ids = [] + for item in name_arr: + ability_feature = self.search([('name', '=', item)]) + if ability_feature: + ability_feature_ids.append(ability_feature.id) + return [(6, 0, ability_feature_ids)] + + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + # 调用父类的name_search方法,获取原始的结果列表 + res = super().name_search(name, args, operator, limit) + # 定义一个空字典用来存储id和name的映射关系 + name_dict = {} + # 遍历结果列表,将id和name存入字典中 + for item in res: + id = item[0] + name = item[1] + name_dict[id] = name + # 根据id列表搜索符合条件的记录 + records = self.browse(name_dict.keys()) + # 定义一个新的结果列表用来存储修改后的结果 + new_res = [] + # 遍历每条记录 + for record in records: + # 获取记录的id,name和image属性 + id = record.id + name = name_dict[id] + image = record.image + # 如果image不为空,将其转换为data URI scheme + if image: + data_uri = f"data:image/png;base64,{image.decode('utf-8')}" + else: + data_uri = "" + # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result + new_res.append([id, name, data_uri]) + # 返回新的结果列表 + return new_res diff --git a/sf_base/models/tool_other_features.py b/sf_base/models/tool_other_features.py new file mode 100644 index 00000000..cb7e8eaf --- /dev/null +++ b/sf_base/models/tool_other_features.py @@ -0,0 +1,383 @@ +from odoo import fields, models, api + + +class ToolMaterialsBasicParameters(models.Model): + _name = 'sf.tool.materials.basic.parameters' + _description = '刀具物料基本参数' + + name = fields.Char('物料号', size=50) + standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具标准库') + cutting_tool_type = fields.Char(related='standard_library_id.cutting_tool_type', string='刀具物料类型', + store=True) + + # 整体式刀具参数 + total_length = fields.Char('总长度(mm)', size=20) + blade_number = fields.Selection( + [('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')], + string='刃数(个)') + neck_diameter = fields.Char('颈部直径(mm)', size=20) + neck_length = fields.Char('颈部长度(mm)', size=20) + handle_diameter = fields.Char('柄部直径(mm)', size=20) + handle_length = fields.Char('柄部长度(mm)', size=20) + blade_tip_diameter = fields.Char('刀尖直径(mm)', size=20) + blade_tip_working_size = fields.Char('刀尖处理尺寸(R半径mm/倒角)', size=20) + blade_tip_taper = fields.Integer('刀尖锥度(°)') + blade_diameter = fields.Char('刃部直径(mm)', size=20) + blade_length = fields.Char('刃部长度(mm)', size=20) + blade_helix_angle = fields.Integer('刃部螺旋角(°)') + blade_width = fields.Char('刃部宽度(mm)', size=20) + blade_depth = fields.Char('刃部深度(mm)', size=20) + pitch = fields.Char('牙距(mm)', size=20) + cutting_depth = fields.Char('切削深度(mm)', size=20) + # 刀片参数 + length = fields.Char('长度(mm)', size=20) + thickness = fields.Char('厚度(mm)', size=20) + width = fields.Char('宽度(mm)', size=20) + cutting_blade_length = fields.Char('切削刃长(mm)', size=20) + relief_angle = fields.Integer('后角(°)') + blade_tip_circular_arc_radius = fields.Char('刀尖圆弧半径(mm)', size=20) + inscribed_circle_diameter = fields.Char('内接圆直径(mm)', size=20) + install_aperture_diameter = fields.Char('安装孔直径(mm)', size=20) + chip_breaker_groove = fields.Selection([('无', '无'), ('单面', '单面'), ('双面', '双面')], + string='有无断屑槽') + blade_teeth_model = fields.Selection( + [('无', '无'), ('V牙型', 'V牙型'), ('米制全牙型', '米制全牙型'), ('美制全牙型', '美制全牙型'), + ('惠氏全牙型', '惠氏全牙型'), ('BSPT全牙型', 'BSPT全牙型'), ('NPT全牙型', 'NPT全牙型'), + ('UNJ全牙型', 'UNJ全牙型'), ('DIN405圆牙型', 'DIN405圆牙型'), ('ACME梯形', 'ACME梯形'), + ('石油管螺纹刀片', '石油管螺纹刀片'), ('矮牙ACME梯形', '矮牙ACME梯形'), + ('Trapeze30° 103', 'Trapeze30° 103')], string='刀片牙型', default='无') + blade_blade_number = fields.Selection([('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), + ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10')], + string='刀片的刃数(个)') + main_included_angle = fields.Integer('主偏角(°)') + top_angle = fields.Integer('顶角(°)') + blade_tip_dip_angle = fields.Integer('刀尖倾角(°)') + side_cutting_edge_angle = fields.Integer('侧切削角(°)') + thread_model = fields.Selection([('无', '无'), ('外螺纹', '外螺纹'), ('内螺纹', '内螺纹')], string='螺纹类型', default='无') + thread_num = fields.Char('每英寸螺纹数(tpi)', size=20) + blade_tip_height_tolerance = fields.Char('刀尖高度公差(mm)', size=20) + inscribed_circle_tolerance = fields.Char('内接圆公差(mm)', size=20) + thickness_tolerance = fields.Char('厚度公差(mm)', size=20) + # 刀杆参数 + height = fields.Char('高度(mm)', size=20) + blade_height = fields.Char('刃部高度(mm)', size=20) + knife_head_height = fields.Char('刀头高度(mm)', size=20) + knife_head_width = fields.Char('刀头宽度(mm)', size=20) + knife_head_length = fields.Char('刀头长度(mm)', size=20) + cut_depth_max = fields.Char('最大切削深度(mm)', size=20) + cutter_arbor_diameter = fields.Char('刀杆直径(mm)', size=20) + min_machining_aperture = fields.Char('最小加工孔径(mm)', size=20) + install_blade_tip_num = fields.Char('可装刀片数/齿数(个)', size=20) + cutting_blade_model = fields.Char('切削类型', size=20) + is_cooling_hole = fields.Boolean('有无冷却孔', default=False) + locating_slot_code = fields.Char('定位槽代号', size=20) + installing_structure = fields.Char('安装结构', size=20) + blade_ids = fields.Many2many( + 'sf.cutting.tool.type', + relation='basic_param_pad_blade_rel', + column1='model_id_1', + column2='model_id_2', + domain="[('cutting_tool_material_id.name', '=', '刀片')]", + string='适配刀片型号' # 使用空列表作为默认值 + ) + tool_shim = fields.Char('适配刀垫型号', size=50) + cotter_pin = fields.Char('适配销钉型号', size=50) + pressing_plate = fields.Char('适配压板型号', size=50) + screw = fields.Char('适配螺钉型号', size=50) + spanner = fields.Char('适配扳手型号', size=50) + # 刀盘参数 + cutter_head_diameter = fields.Char('刀盘直径(mm)', size=20) + interface_diameter = fields.Char('接口直径(mm)', size=20) + # 刀柄参数 + flange_shank_length = fields.Char('法兰柄长(mm)', size=20) + handle_external_diameter = fields.Char('柄部外径(mm)', size=20) + handle_inside_diameter = fields.Char('柄部内径(mm)', size=20) + min_clamping_diameter = fields.Char('最小夹持直径(mm)', size=20) + max_clamping_diameter = fields.Char('最大夹持直径(mm)', size=20) + clamping_mode = fields.Char('夹持方式', size=20) + max_load_capacity = fields.Char('最大负载能力(kg)', size=20) + taper = fields.Integer('锥度(°)') + tool_changing_time = fields.Integer('换刀时间(s)') + standard_rotate_speed = fields.Char('标准转速(n/min)', size=20) + max_rotate_speed = fields.Char('最大转速(n/min)', size=20) + diameter_slip_accuracy = fields.Char('径跳精度(mm)', size=20) + cooling_model = fields.Char('冷却类型', size=20) + is_rough_machining = fields.Boolean('可粗加工', default=False) + is_finish_machining = fields.Boolean('可精加工', default=False) + is_quick_cutting = fields.Boolean('可高速切削', default=False) + is_drill_hole = fields.Boolean('可钻孔', default=False) + is_safe_lock = fields.Boolean('有无安全锁', default=False) + # 夹头参数 + er_size_model = fields.Char('ER尺寸型号', size=20) + outer_diameter = fields.Char('外径(mm)', size=20) + inner_diameter = fields.Char('内径(mm)', size=20) + run_out_accuracy = fields.Char('跳动精度(mm)', size=20) + top_diameter = fields.Char('顶部直径(mm)', size=20) + weight = fields.Char('重量(kg)', size=20) + clamping_length = fields.Char('夹持长度(mm)', size=20) + clamping_tolerance = fields.Char('夹持公差(mm)', size=20) + cooling_jacket = fields.Char('适用冷却套型号', size=50) + handle_ids = fields.Many2many( + 'sf.cutting.tool.type', + relation='basic_param_chuck_handle_rel', + column1='model_id_1', + column2='model_id_2', + domain="[('cutting_tool_material_id.name', '=', '刀柄')]", + string='适用刀柄型号' + ) + + def _json_integral_tool_basic_param(self, obj): + integral_tool_basic_param_str = (0, '', { + 'name': obj['name'], + 'cutting_tool_type': obj['cutting_tool_type'], + 'total_length': obj['total_length'], + 'blade_diameter': obj['blade_diameter'], + 'blade_length': obj['blade_length'], + 'blade_number': obj['blade_number'], + 'neck_length': obj['neck_length'], + 'neck_diameter': obj['neck_diameter'], + 'handle_diameter': obj['handle_diameter'], + 'handle_length': obj['handle_length'], + 'blade_tip_diameter': obj['blade_tip_diameter'], + 'blade_tip_working_size': obj['blade_tip_working_size'], + 'blade_tip_taper': obj['blade_tip_taper'], + 'blade_helix_angle': obj['blade_helix_angle'], + 'blade_width': obj['blade_width'], + 'blade_depth': obj['blade_depth'], + 'pitch': obj['pitch'], + 'cutting_depth': obj['cutting_depth'], + }) + return integral_tool_basic_param_str + + def _json_blade_basic_param(self, obj): + blade_basic_param_str = (0, '', { + 'name': obj['name'], + 'cutting_tool_type': obj['cutting_tool_type'], + 'length': obj['length'], + 'thickness': obj['thickness'], + 'width': obj['width'], + 'cutting_blade_length': obj['cutting_blade_length'], + 'relief_angle': obj['relief_angle'], + 'blade_tip_circular_arc_radius': obj['blade_tip_circular_arc_radius'], + 'inscribed_circle_diameter': obj['inscribed_circle_diameter'], + 'install_aperture_diameter': obj['install_aperture_diameter'], + 'pitch': obj['pitch'], + 'chip_breaker_groove': obj['chip_breaker_groove'], + 'blade_teeth_model': '无' if not obj['bladed_teeth_model'] else obj['bladed_teeth_model'], + 'blade_blade_number': obj['blade_blade_number'], + 'cutting_depth': obj['cutting_depth'], + 'blade_width': obj['blade_width'], + 'main_included_angle': obj['main_included_angle'], + 'top_angle': obj['top_angle'], + 'blade_tip_dip_angle': obj['blade_tip_dip_angle'], + 'side_cutting_edge_angle': obj['side_cutting_edge_angle'], + 'thread_model': '无' if not obj['thread_model'] else obj['thread_model'], + 'thread_num': obj['thread_num'], + 'blade_tip_height_tolerance': obj['blade_tip_height_tolerance'], + 'inscribed_circle_tolerance': obj['inscribed_circle_tolerance'], + 'thickness_tolerance': obj['thickness_tolerance'], + }) + return blade_basic_param_str + + def _json_cutter_arbor_basic_param(self, obj): + cutter_arbor_basic_param_str = (0, '', { + 'name': obj['name'], + 'cutting_tool_type': obj['cutting_tool_type'], + 'height': obj['height'], + 'width': obj['width'], + 'total_length': obj['total_length'], + 'knife_head_height': obj['knife_head_height'], + 'knife_head_width': obj['knife_head_width'], + 'knife_head_length': obj['knife_head_length'], + 'cutter_arbor_diameter': obj['cutter_arbor_diameter'], + 'main_included_angle': obj['main_included_angle'], + 'relief_angle': obj['relief_angle'], + 'cutting_depth': obj['cutting_depth'], + 'min_machining_aperture': obj['min_machining_aperture'], + 'install_blade_tip_num': obj['install_blade_tip_num'], + 'cutting_blade_model': obj['cutting_blade_model'], + 'is_cooling_hole': obj['is_cooling_hole'], + 'locating_slot_code': obj['locating_slot_code'], + 'installing_structure': obj['installing_structure'], + 'blade_ids': [(6, 0, [])] if not obj.get('blade_codes') else self.evn['sf.cutting_tool.standard.library']._get_ids( + obj['blade_codes']), + 'tool_shim': obj['tool_shim'], + 'cotter_pin': obj['cotter_pin'], + 'pressing_plate': obj['pressing_plate'], + 'screw': obj['screw'], + 'spanner': obj['spanner'], + }) + return cutter_arbor_basic_param_str + + def _json_cutter_head_basic_param(self, obj): + cutter_head_basic_param_str = (0, '', { + 'name': obj['name'], + 'cutting_tool_type': obj['cutting_tool_type'], + 'install_blade_tip_num': obj['install_blade_tip_num'], + 'blade_diameter': obj['blade_diameter'], + 'cutter_head_diameter': obj['cutter_head_diameter'], + 'interface_diameter': obj['interface_diameter'], + 'total_length': obj['total_length'], + 'blade_length': obj['blade_length'], + 'cutting_depth': obj['cutting_depth'], + 'main_included_angle': obj['main_included_angle'], + 'installing_structure': obj['installing_structure'], + 'blade_ids': [(6, 0, [])] if not obj.get('blade_codes') else self.evn['sf.cutting_tool.standard.library']._get_ids( + obj['blade_codes']), + 'screw': obj['screw'], + 'spanner': obj['spanner'], + 'cutting_blade_model': obj['cutting_blade_model'], + 'is_cooling_hole': obj['is_cooling_hole'], + 'locating_slot_code': obj['locating_slot_code'], + }) + return cutter_head_basic_param_str + + def _json_knife_handle_basic_param(self, obj): + knife_handle_basic_param_str = (0, '', { + 'name': obj['name'], + 'cutting_tool_type': obj['cutting_tool_type'], + 'total_length': obj['total_length'], + 'flange_shank_length': obj['flange_shank_length'], + 'handle_external_diameter': obj['handle_external_diameter'], + 'handle_inside_diameter': obj['handle_inside_diameter'], + 'min_clamping_diameter': obj['min_clamping_diameter'], + 'max_clamping_diameter': obj['max_clamping_diameter'], + 'clamping_mode': obj['clamping_mode'], + 'max_load_capacity': obj['max_load_capacity'], + 'taper': obj['taper'], + 'tool_changing_time': obj['tool_changing_time'], + 'standard_rotate_speed': obj['standard_rotate_speed'], + 'max_rotate_speed': obj['max_rotate_speed'], + 'diameter_slip_accuracy': obj['diameter_slip_accuracy'], + 'cooling_model': obj['cooling_model'], + 'is_rough_machining': obj['is_rough_machining'], + 'is_finish_machining': obj['is_finish_machining'], + 'is_quick_cutting': obj['is_quick_cutting'], + 'is_drill_hole': obj['is_drill_hole'], + 'is_safe_lock': obj['is_safe_lock'], + 'screw': obj['screw'], + 'spanner': obj['spanner'], + }) + return knife_handle_basic_param_str + + def _json_chuck_basic_param(self, obj): + chuck_basic_param_str = (0, '', { + 'name': obj['name'], + 'cutting_tool_type': obj['cutting_tool_type'], + 'er_size_model': obj['er_size_model'], + 'min_clamping_diameter': obj['min_clamping_diameter'], + 'max_clamping_diameter': obj['max_clamping_diameter'], + 'outer_diameter': obj['outer_diameter'], + 'inner_diameter': obj['inner_diameter'], + 'run_out_accuracy': obj['run_out_accuracy'], + 'total_length': obj['total_length'], + 'taper': obj['taper'], + 'run_out_accuracy': obj['run_out_accuracy'], + 'top_diameter': obj['top_diameter'], + 'weight': obj['weight'], + 'clamping_mode': obj['clamping_mode'], + 'clamping_length': obj['clamping_length'], + 'clamping_tolerance': obj['clamping_tolerance'], + 'max_load_capacity': obj['max_load_capacity'], + 'handle_ids': [(6, 0, [])] if not obj.get( + 'handle_codes') else self.evn['sf.cutting_tool.standard.library']._get_ids(obj['handle_codes']), + 'cooling_jacket': obj['cooling_jacket'], + }) + return chuck_basic_param_str + + +class CuttingSpeed(models.Model): + _name = 'sf.cutting.speed' + _description = '切削速度Vc' + + product_template_id = fields.Many2one('product.template') + standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='标准库') + execution_standard_id = fields.Many2one('sf.international.standards', string='执行标准', store=True) + material_code = fields.Char('材料代号') + material_id = fields.Many2one('sf.materials.model', '材料名称', + domain="[('standards_id', '=', execution_standard_id)]") + slope_milling_angle = fields.Integer('坡铣角度(°)') + material_grade = fields.Char('材料牌号') + tensile_strength = fields.Char('拉伸强度 (N/mm²)') + hardness = fields.Float('硬度(HRC)') + cutting_speed_n1 = fields.Char('径向切宽 ae=100%D1 ap=1*D1 切削速度Vc') + cutting_speed_n2 = fields.Char('径向切宽 ae=50%D1 ap=1.5*D1 切削速度Vc') + cutting_speed_n3 = fields.Char('径向切宽 ae=25%D1 ap=L1max 切削速度Vc') + cutting_speed_n4 = fields.Char('径向切宽 ae=15%D1 ap=L1max 切削速度Vc') + cutting_speed_n5 = fields.Char('径向切宽 ae=5%D1 ap=L1max 切削速度Vc') + rough_machining = fields.Char('粗加工 Vc(m/min)') + precision_machining = fields.Char('精加工 Vc(m/min)') + application = fields.Selection([('主应用', '主应用'), ('次应用', '次应用')], '主/次应用') + + def _json_cutting_speed(self, obj): + cutting_speed_str = (0, '', { + 'execution_standard_id': self.env['sf.international.standards'].search( + [('code', '=', obj['execution_standard_code'])]).id, + 'material_code': obj['material_code'], + 'material_id': self.env['sf.materials.model'].search([('materials_no', '=', obj['material_name_code'])]).id, + 'material_grade': obj['material_grade'], + 'tensile_strength': obj['tensile_strength'], + 'hardness': obj['hardness'], + 'cutting_speed_n1': obj['cutting_speed_n1'], + 'cutting_speed_n2': obj['cutting_speed_n2'], + 'cutting_speed_n3': obj['cutting_speed_n3'], + 'cutting_speed_n4': obj['cutting_speed_n4'], + 'cutting_speed_n5': obj['cutting_speed_n5'], + 'rough_machining': obj['rough_machining'], + 'precision_machining': obj['precision_machining'], + 'application': obj['application'], + }) + return cutting_speed_str + + +class FeedPerTooth(models.Model): + _name = 'sf.feed.per.tooth' + _description = '每齿走刀量fz' + _order = 'machining_method desc, blade_diameter, materials_type_id' + + product_template_id = fields.Many2one('product.template') + standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='标准库') + cutting_speed = fields.Char('径向切宽 ae(mm)') + machining_method = fields.Selection([('直铣', '直铣'), ('坡铣', '坡铣')], string='加工方式') + materials_type_id = fields.Many2one('sf.materials.model', string='材料型号') + blade_diameter = fields.Char('刃部直径(mm)', readonly=True) + feed_per_tooth = fields.Char('每齿走刀量 (mm/z)') + + def _json_feed_per_tooth(self, obj): + feed_per_tooth_str = (0, '', { + 'cutting_speed': obj['cutting_speed'], + 'blade_diameter': obj['blade_diameter'], + 'feed_per_tooth': obj['feed_per_tooth'], + }) + return feed_per_tooth_str + + def _json_feed_per_tooth_2(self, obj): + feed_per_tooth_2_str = (0, '', { + 'machining_method': obj['machining_method'], + 'materials_type_id': self.env['sf.materials.model'].search( + [('materials_no', '=', obj['materials_type_code'])]).id, + 'blade_diameter': obj['blade_diameter'], + 'feed_per_tooth': obj['feed_per_tooth'], + }) + return feed_per_tooth_2_str + + def _json_feed_per_tooth_3(self, obj): + feed_per_tooth_3_str = (0, '', { + 'cutting_speed': obj['cutting_speed'], + 'feed_per_tooth': obj['feed_per_tooth'], + }) + return feed_per_tooth_3_str + + def _json_feed_per_tooth_4(self, obj): + feed_per_tooth_4_str = (0, '', { + 'machining_method': obj['machining_method'], + 'materials_type_id': self.env['sf.materials.model'].search( + [('materials_no', '=', obj['materials_type_code'])]).id, + 'feed_per_tooth': obj['feed_per_tooth'], + }) + return feed_per_tooth_4_str + + # @api.depends('product_template_id') + # def _compute_product_template_id(self): + # if self.product_template_id is not None: + # self.blade_diameter = self.product_template_id.cutting_tool_blade_diameter diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 1829085c..37daa2b3 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -15,7 +15,6 @@ access_sf_production_process_category,sf_production_process_category,model_sf_pr access_sf_machine_tool_category,sf_machine_tool_category,model_sf_machine_tool_category,base.group_user,1,1,1,1 access_sf_cutting_tool_material,sf_cutting_tool_material,model_sf_cutting_tool_material,base.group_user,1,1,1,1 access_sf_cutting_tool_type,sf_cutting_tool_type,model_sf_cutting_tool_type,base.group_user,1,1,1,1 -access_sf_cutting_tool_model,sf_cutting_tool_model,model_sf_cutting_tool_model,base.group_user,1,1,1,1 access_sf_functional_cutting_tool,sf_functional_cutting_tool,model_sf_functional_cutting_tool,base.group_user,1,1,1,1 access_sf_functional_cutting_tool_model,sf_functional_cutting_tool_model,model_sf_functional_cutting_tool_model,base.group_user,1,1,1,1 access_sf_fixture_material,sf_fixture_material,model_sf_fixture_material,base.group_user,1,1,1,1 @@ -26,6 +25,12 @@ access_sf_functional_fixture,sf_functional_fixture,model_sf_functional_fixture,b access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,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_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 +access_maintenance_equipment_image,maintenance_equipment_image,model_maintenance_equipment_image,base.group_user,1,1,1,1 + diff --git a/sf_base/static/src/scss/test.scss b/sf_base/static/src/scss/test.scss index a54eb808..a2992e1a 100644 --- a/sf_base/static/src/scss/test.scss +++ b/sf_base/static/src/scss/test.scss @@ -161,4 +161,25 @@ td.o_required_modifier { display: flex !important; justify-content: flex-start !important; align-items: center !important; -} \ No newline at end of file +} + +//用于label外的div +.type_label { + display: flex; + align-items: center; +} + +.button_width button { + width:11rem; + margin-top: -9px; + height: 2.5rem; + line-height: 1.5rem; +} + +.button_width{ + display: flex; +} +.o_field_widget.o_field_many2one { + flex-direction: row !important; +} + diff --git a/sf_base/views/tool_base_menu.xml b/sf_base/views/tool_base_menu.xml deleted file mode 100644 index 6bd12d74..00000000 --- a/sf_base/views/tool_base_menu.xml +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - 整体式刀具型号 - ir.actions.act_window - sf.integral.cutting.tool - - tree,form - - - - 功能刀具 - ir.actions.act_window - sf.functional.cutting.tool - tree,form - - - - 刀片型号 - ir.actions.act_window - sf.blade - tree,form - - - - 刀杆型号 - ir.actions.act_window - sf.cutter.bar - tree,form - - - - 刀盘型号 - ir.actions.act_window - sf.cutter.pad - tree,form - - - - 刀柄型号 - ir.actions.act_window - sf.handle - tree,form - - - - 夹头型号 - ir.actions.act_window - sf.chuck - tree,form - - - - 功能刀具类型 - ir.actions.act_window - sf.functional.cutting.tool.model - tree,form - - - - 整体式刀具类型 - ir.actions.act_window - sf.integral.cutting.tool.model - tree,form - - - - 刀片类型 - ir.actions.act_window - sf.blade.model - tree,form - - - - 刀杆类型 - ir.actions.act_window - sf.cutter.bar.model - tree,form - - - - 刀盘类型 - ir.actions.act_window - sf.cutter.pad.model - tree,form - - - - 刀柄类型 - ir.actions.act_window - sf.handle.model - tree,form - - - - 夹头类型 - ir.actions.act_window - sf.chuck.model - tree,form - - - - 刀具物料 - ir.actions.act_window - sf.cutting.tool.material - tree,form - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sf_base/views/tool_base_views.xml b/sf_base/views/tool_base_views.xml deleted file mode 100644 index ce16146c..00000000 --- a/sf_base/views/tool_base_views.xml +++ /dev/null @@ -1,849 +0,0 @@ - - - - - - sf.cutting.tool.material.tree - sf.cutting.tool.material - - - - - - - - - - - sf.cutting.tool.material.form - sf.cutting.tool.material - -
- - - - - - - - - - - - - -
-
-
- - - - - sf.cutting.tool.material.search - sf.cutting.tool.material - - - - - - - - - - - sf.functional.cutting.tool.tree - sf.functional.cutting.tool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sf.functional.cutting.tool.form - sf.functional.cutting.tool - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - sf.functional.cutting.tool.search - sf.functional.cutting.tool - - - - - - - - - - - sf.integral.cutting.tool.tree - sf.integral.cutting.tool - - - - - - - - - - - - - - - sf.integral.cutting.tool.form - sf.integral.cutting.tool - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - sf.integral.cutting.tool.search - sf.integral.cutting.tool - - - - - - - - - - sf.blade.tree - sf.blade - - - - - - - - - - - - - sf.blade.form - sf.blade - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - sf.blade.search - sf.blade - - - - - - - - - - sf.cutter.bar.tree - sf.cutter.bar - - - - - - - - - - - - - sf.cutter.bar.form - sf.cutter.bar - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - sf.cutter.bar.search - sf.cutter.bar - - - - - - - - - - - sf.cutter.pad.tree - sf.cutter.pad - - - - - - - - - - - - - sf.cutter.pad.form - sf.cutter.pad - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - sf.cutter.pad.search - sf.cutter.pad - - - - - - - - - - - sf.cutter.handle.tree - sf.handle - - - - - - - - - - - - - sf.cutter.handle.form - sf.handle - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - sf.handle.search - sf.handle - - - - - - - - - - - sf.cutter.chuck.tree - sf.chuck - - - - - - - - - - - - - sf.cutter.chuck.form - sf.chuck - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - sf.chuck.search - sf.chuck - - - - - - - - - - - sf.cutter.function.tree - sf.functional.cutting.tool.model - - - - - - - - - - - - sf.cutter.function.form - sf.functional.cutting.tool.model - -
- - - - - - - - - - - -
-
-
- - - sf.integral.cutting.tool.model.tree - sf.integral.cutting.tool.model - - - - - - - - - - - - sf.integral.cutting.tool.model.form - sf.integral.cutting.tool.model - -
- - - - - - - - - - - - -
-
-
- - - sf.blade.model.tree - sf.blade.model - - - - - - - - - - - - sf.blade.model.form - sf.blade.model - -
- - - - - - - - - - - - -
-
-
- - - sf.cutter.bar.model.tree - sf.cutter.bar.model - - - - - - - - - - - - sf.cutter.bar.model.form - sf.cutter.bar.model - -
- - - - - - - - - - - - -
-
-
- - - sf.cutter.pad.model.tree - sf.cutter.pad.model - - - - - - - - - - - - sf.cutter.pad.model.form - sf.cutter.pad.model - -
- - - - - - - - - - - - -
-
-
- - - - sf.handle.model.tree - sf.handle.model - - - - - - - - - - - - sf.handle.model.form - sf.handle.model - -
- - - - - - - - - - - - -
-
-
- - - sf.chuck.model.tree - sf.chuck.model - - - - - - - - - - - - sf.chuck.model.form - sf.chuck.model - -
- - - - - - - - - - - - -
-
-
-
-
diff --git a/sf_base/views/tool_basic_param.xml b/sf_base/views/tool_basic_param.xml new file mode 100644 index 00000000..a512de10 --- /dev/null +++ b/sf_base/views/tool_basic_param.xml @@ -0,0 +1,134 @@ + + + + + + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + + + + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + + + + + + sf.tool.materials.basic.parameters.tree + sf.tool.materials.basic.parameters + + + + + + + + + + + + + + + + + + + + + + + + + sf.tool.materials.basic.parameters.search + sf.tool.materials.basic.parameters + + + + + + + + + 基础参数 + sf.tool.materials.basic.parameters + tree + + + [] + + + + + diff --git a/sf_base/views/tool_menu.xml b/sf_base/views/tool_menu.xml index 4f6bb693..cddb7d90 100644 --- a/sf_base/views/tool_menu.xml +++ b/sf_base/views/tool_menu.xml @@ -16,11 +16,11 @@ sf.cutting.tool.type tree - - - 刀具型号 + + + 刀具标准库 ir.actions.act_window - sf.cutting.tool.model + sf.cutting_tool.standard.library tree,form @@ -61,14 +61,13 @@ sequence="2" action="action_sf_cutting_tool_type" /> - - - - - - - - + @@ -86,5 +85,12 @@ action="action_sf_functional_cutting_tool_model_type" /> + + diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index ee5546a8..c1e03123 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -14,29 +14,6 @@ - - - - - - - - - - - - - - - - - - - - - - - sf.cutting.tool.material.search sf.cutting.tool.material @@ -58,13 +35,6 @@ - - - - - - - @@ -83,52 +53,9 @@ - - - - - - - - - - - - - - - - - - + options="{'no_create': True, 'no_quick_create': True}"/> - - - - - - - - - - - - - - - - - - - - - - - - @@ -160,25 +87,6 @@ - - - - - - - - - - - - - - - - - - - @@ -193,130 +101,323 @@ - - - sf.cutting.tool.model.tree - sf.cutting.tool.model + + + sf.cutting_tool.standard.library.tree + sf.cutting_tool.standard.library - - - + + + + + - - sf.cutting.tool.model.form - sf.cutting.tool.model + + sf.cutting_tool.standard.library.form + sf.cutting_tool.standard.library -
+ +

- +

- - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -324,17 +425,16 @@ - - - sf.cutting.tool.model.search - sf.cutting.tool.model + + sf.cutting_tool.standard.library.search + sf.cutting_tool.standard.library - + @@ -355,27 +455,6 @@ - - - - - - - - - - - - - - - - - - - - - sf.cutting.tool.type.search @@ -391,6 +470,72 @@ - + + + + maintenance.equipment.image.tree + maintenance.equipment.image + + + + + + + + + + + + + + maintenance.equipment.image.search + maintenance.equipment.image + + + + + + + + + + 能力特征库 + maintenance.equipment.image + tree + [] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sf_dlm/__init__.py b/sf_dlm/__init__.py index 737b4772..8b137891 100644 --- a/sf_dlm/__init__.py +++ b/sf_dlm/__init__.py @@ -1 +1 @@ -# from . import models + diff --git a/sf_dlm/__manifest__.py b/sf_dlm/__manifest__.py index ed717647..ed9e2053 100644 --- a/sf_dlm/__manifest__.py +++ b/sf_dlm/__manifest__.py @@ -10,11 +10,14 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['mrp', 'base', 'sale', 'sf_manufacturing', 'web_widget_model_viewer', 'mrp_subcontracting', 'purchase_stock', - 'uom','jikimo_frontend'], + 'depends': ['mrp', 'base', 'sf_manufacturing', 'web_widget_model_viewer', 'mrp_subcontracting', + 'purchase_stock', + 'uom', 'jikimo_frontend', 'product'], 'data': [ 'data/product_data.xml', 'data/uom_data.xml', + 'security/ir.model.access.csv', + # 'wizard/cutting_tool_specification_wizard.xml', 'views/product_template_view.xml', 'views/product_workorder.xml' ], diff --git a/sf_dlm/security/group_security.xml b/sf_dlm/security/group_security.xml new file mode 100644 index 00000000..b8668782 --- /dev/null +++ b/sf_dlm/security/group_security.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sf_dlm/security/ir.model.access.csv b/sf_dlm/security/ir.model.access.csv new file mode 100644 index 00000000..fd6de5be --- /dev/null +++ b/sf_dlm/security/ir.model.access.csv @@ -0,0 +1,11 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink + + + + + + + + + + diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index a1322117..b212ddef 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -1,19 +1,19 @@ - - product.template.only.form.inherit.sf - product.template - - - - - - - - - - + + + + + + + + + + + + + product.template.form.inherit.sf @@ -52,15 +52,21 @@ + + + + + - + + + + @@ -102,74 +108,169 @@ - + + + + + + + + + + product.template.only.form.inherit.sf + product.template + + + + + + + + + - + - + attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀杆','刀盘','夹头','刀柄'))]}"/> + + - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sf_maintenance/models/sf_equipment_maintenance_standards.py b/sf_maintenance/models/sf_equipment_maintenance_standards.py index 55fea8b0..80ec2ba3 100644 --- a/sf_maintenance/models/sf_equipment_maintenance_standards.py +++ b/sf_maintenance/models/sf_equipment_maintenance_standards.py @@ -48,8 +48,8 @@ class SfEquipmentSaintenanceStandards(models.Model): string='适用设备', domain="[('category_id', '=', maintenance_equipment_category_id)]" ) - - maintenance_standards_ids = fields.One2many('maintenance.standards', 'equipment_maintenance_standards_id', string='维保项目') + maintenance_standards_ids = fields.One2many('maintenance.standards', 'equipment_maintenance_standards_id', + string='维保项目', widget='one2many_list') eq_maintenance_ids = fields.One2many('maintenance.equipment', 'eq_maintenance_id', string='保养设备') overhaul_ids = fields.One2many('maintenance.equipment', 'overhaul_id', string='检修设备') @@ -81,6 +81,7 @@ class SfSaintenanceStandards(models.Model): [('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='类别') equipment_maintenance_standards_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准') images = fields.One2many('maintenance.standard.image', 'standard_id', string='反馈图片') + maintenance_request_ids = fields.Many2many('maintenance.request', string='维保计划') Period = fields.Integer('周期/频次(天)') remark = fields.Char('备注说明') diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index 5c916387..c44f283c 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -237,9 +237,9 @@ class SfMaintenanceEquipment(models.Model): item.brand_id = item.type_id.brand_id.id # AGV小车设备参数 - AGV_L = fields.Char('设备尺寸(长)') - AGV_W = fields.Char('设备尺寸(宽)') - AGV_H = fields.Char('设备尺寸(高)') + AGV_L = fields.Char('AGV尺寸(长)') + AGV_W = fields.Char('AGV尺寸(宽)') + AGV_H = fields.Char('AGV尺寸(高)') AGV_goods_L = fields.Char('载货尺寸(长)') AGV_goods_W = fields.Char('载货尺寸(宽)') AGV_goods_H = fields.Char('载货尺寸(高)') @@ -276,9 +276,9 @@ class SfMaintenanceEquipment(models.Model): detect_L = fields.Char('设备尺寸(长)') detect_W = fields.Char('设备尺寸(宽)') detect_H = fields.Char('设备尺寸(高)') - detect_x_axis = fields.Char('X轴') - detect_y_axis = fields.Char('Y轴') - detect_z_axis = fields.Char('Z轴') + detect_x_axis = fields.Char('检测X轴') + detect_y_axis = fields.Char('检测Y轴') + detect_z_axis = fields.Char('检测Z轴') detect_precision = fields.Char('测量精度') detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), ('激光干涉仪', '激光干涉仪')], string='测量方式') detect_resolution = fields.Char('分辨率') @@ -295,8 +295,8 @@ class SfMaintenanceEquipment(models.Model): detect_object_field_of_view_max = fields.Char('物方视场(最大)') detect_object_field_of_view_min = fields.Char('物方视场(最小)') detect_power_requirements = fields.Char('电源要求') - detect_operating_temperature = fields.Char('环境温度') - detect_operating_humidity = fields.Char('环境湿度') + detect_operating_temperature = fields.Char('检测设备环境温度') + detect_operating_humidity = fields.Char('检测设备环境湿度') # 机器人设备参数 robot_gripping_of_workpieces_L = fields.Char('可抓取工件(长)') @@ -313,8 +313,8 @@ class SfMaintenanceEquipment(models.Model): robot_track_dimensions_H = fields.Char('轨道尺寸(高)') robot_drive_mode = fields.Char('驱动方式') robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], string='安装方式') - robot_operating_temperature = fields.Char('环境温度') - robot_operating_humidity = fields.Char('环境湿度') + robot_operating_temperature = fields.Char('机器人环境温度') + robot_operating_humidity = fields.Char('机器人环境湿度') # 其他参数(所有设备) date_of_purchase = fields.Date('采购日期') @@ -582,50 +582,6 @@ class SfMaintenanceEquipment(models.Model): image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', domain="[('type', '=', '加工能力')]") -class MaintenanceStandardImage(models.Model): - _name = 'maintenance.equipment.image' - _description = '能力特征库' - - active = fields.Boolean('有效', default=True) - name = fields.Char('名称') - image = fields.Binary(string='图文') - type = fields.Selection( - [('加工能力', '加工能力'), ('刀尖特征', '刀尖特征'), ('柄部类型', '柄部类型'), ('走刀方向', '走刀方向'), - ('冷却液', '冷却液'), ('压紧方式', '压紧方式'), ('刀片形状', '刀片形状')], - string='特征') - equipment_id = fields.Many2many('maintenance.equipment', 'image_id', string='设备') - - @api.model - def name_search(self, name='', args=None, operator='ilike', limit=100): - # 调用父类的name_search方法,获取原始的结果列表 - res = super().name_search(name, args, operator, limit) - # 定义一个空字典用来存储id和name的映射关系 - name_dict = {} - # 遍历结果列表,将id和name存入字典中 - for item in res: - id = item[0] - name = item[1] - name_dict[id] = name - # 根据id列表搜索符合条件的记录 - records = self.browse(name_dict.keys()) - # 定义一个新的结果列表用来存储修改后的结果 - new_res = [] - # 遍历每条记录 - for record in records: - # 获取记录的id,name和image属性 - id = record.id - name = name_dict[id] - image = record.image - # 如果image不为空,将其转换为data URI scheme - if image: - data_uri = f"data:image/png;base64,{image.decode('utf-8')}" - else: - data_uri = "" - # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result - new_res.append([id, name, data_uri]) - # 返回新的结果列表 - return new_res - class SfRobotAxisNum(models.Model): _name = 'sf.robot.axis.num' _description = '机器人轴参数' diff --git a/sf_maintenance/models/sf_maintenance_requests.py b/sf_maintenance/models/sf_maintenance_requests.py index fad9e55f..330c1ece 100644 --- a/sf_maintenance/models/sf_maintenance_requests.py +++ b/sf_maintenance/models/sf_maintenance_requests.py @@ -25,7 +25,7 @@ class SfMaintenanceEquipmentCategory(models.Model): if not record.equipment_maintenance_id: record.equipment_maintenance_id = False - maintenance_standards = fields.Many2many('maintenance.standards', string='维保标准') + maintenance_standards = fields.Many2many('maintenance.standards', string='维保项目') @api.constrains('equipment_maintenance_id') def _check_equipment_maintenance_id(self): diff --git a/sf_maintenance/security/ir.model.access.csv b/sf_maintenance/security/ir.model.access.csv index 65e93d7a..5a022f14 100644 --- a/sf_maintenance/security/ir.model.access.csv +++ b/sf_maintenance/security/ir.model.access.csv @@ -4,7 +4,6 @@ access_sf_maintenance_logs,sf_maintenance_logs,model_sf_maintenance_logs,base.gr access_maintenance_equipment,maintenance_equipment,model_maintenance_equipment,base.group_user,1,1,1,1 access_maintenance_standards,maintenance_standards,model_maintenance_standards,base.group_user,1,1,1,1 access_maintenance_standard_image,maintenance_standard_image,model_maintenance_standard_image,base.group_user,1,1,1,1 -access_maintenance_equipment_image,maintenance_equipment_image,model_maintenance_equipment_image,base.group_user,1,1,1,1 access_sf_robot_axis_num,sf_robot_axis_num,model_sf_robot_axis_num,base.group_user,1,1,1,1 diff --git a/sf_maintenance/views/maintenance_request_views.xml b/sf_maintenance/views/maintenance_request_views.xml index 83bd6e44..1ad030b8 100644 --- a/sf_maintenance/views/maintenance_request_views.xml +++ b/sf_maintenance/views/maintenance_request_views.xml @@ -1,5 +1,63 @@ + + + + + maintenance.standards.form + maintenance.standards + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
+
+ + + + + + +
+
+ +
+
+ +
+
+ + + Maintenance Standards + maintenance.standards + tree,form + + @@ -21,17 +79,16 @@ - - - - - + + + + - + + - @@ -71,40 +128,5 @@ - - - - maintenance.standards.form - maintenance.standards - -
- - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
\ No newline at end of file diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 0ebd997d..435e291c 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -1136,6 +1136,7 @@ + maintenance.equipment.image.tree maintenance.equipment.image @@ -1188,4 +1189,5 @@ sequence="0"/> +
\ No newline at end of file diff --git a/sf_manufacturing/__init__.py b/sf_manufacturing/__init__.py index 0650744f..7c378d64 100644 --- a/sf_manufacturing/__init__.py +++ b/sf_manufacturing/__init__.py @@ -1 +1,3 @@ from . import models + + diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index e2be4958..9800bf5d 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -21,7 +21,6 @@ 'views/production_line_view.xml', 'views/mrp_workcenter_views.xml', 'views/mrp_workorder_view.xml', - 'views/tool_other_features_view.xml', 'views/model_type_view.xml', 'views/sf_maintenance_equipment.xml', # 'views/kanban_change.xml' diff --git a/sf_manufacturing/models/__init__.py b/sf_manufacturing/models/__init__.py index 25b91f15..cb14176c 100644 --- a/sf_manufacturing/models/__init__.py +++ b/sf_manufacturing/models/__init__.py @@ -8,7 +8,6 @@ from . import mrp_routing_workcenter from . import stock from . import res_user from . import production_line_base -from . import tool_other_features diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index ae4ccd53..b1efb4a3 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -1,12 +1,15 @@ -from odoo import models, fields, api +from odoo import models, fields, api, _ from odoo.exceptions import ValidationError from odoo.modules import get_resource_path +from odoo.addons.sf_base.commons.common import Common from OCC.Extend.DataExchange import read_step_file from OCC.Extend.DataExchange import write_stl_file import logging import base64 import hashlib import os +import requests +import json class ResProductMo(models.Model): @@ -44,7 +47,6 @@ class ResProductMo(models.Model): width = fields.Float('宽(mm)', digits=(16, 3)) height = fields.Float('高(mm)', digits=(16, 3)) single_manufacturing = fields.Boolean(string="单个制造") - model_code = fields.Char('模型编码') is_bfm = fields.Boolean('业务平台是否自动创建', default=False) upload_model_file = fields.Many2many('ir.attachment', 'upload_model_file_attachment_ref', string='上传模型文件') @@ -60,16 +62,18 @@ class ResProductMo(models.Model): cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料') cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True) - cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='型号', - ) + cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号') + specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='规格') + cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型', domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]") brand_id = fields.Many2one('sf.machine.brand', '品牌') + tool_length = fields.Float('长度(mm)') tool_width = fields.Float('宽度(mm)') tool_height = fields.Float('高度(mm)') - tool_thickness = fields.Integer('厚度(mm)') + tool_thickness = fields.Float('厚度(mm)') tool_weight = fields.Float('重量(kg)') tool_hardness = fields.Integer('硬度(hrc)') @@ -77,7 +81,7 @@ class ResProductMo(models.Model): # 整体式刀具特有字段 cutting_tool_total_length = fields.Float('总长度(mm)', digits=(6, 1)) cutting_tool_shank_length = fields.Float('柄部长度(mm)', digits=(6, 1)) - cutting_tool_blade_length = fields.Float('刃部长度(mm)', digits=(6, 1)) + cutting_tool_blade_length = fields.Char('刃部长度(mm)') cutting_tool_blade_number = fields.Selection( [('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')], '刃数(个)') # 整体式刀具新增字段 @@ -88,13 +92,21 @@ class ResProductMo(models.Model): cutting_tool_blade_tip_taper = fields.Integer('刀尖锥度(°)') cutting_tool_blade_helix_angle = fields.Integer('刃部螺旋角(°)') cutting_tool_blade_type = fields.Char('刃部类型') + cutting_tool_pitch = fields.Char('牙距(mm)', size=20) + cutting_tool_blade_width = fields.Char('刃部宽度(mm)', size=20) + cutting_tool_blade_depth = fields.Char('刃部深度(mm)', size=20) + cutting_tool_cut_depth = fields.Char('切削深度(mm)', size=20) + cutting_tool_cut_depth_max = fields.Char('最大切削深度(mm)', size=20) cutting_tool_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '粗/中/精') cutting_tool_run_out_accuracy_max = fields.Float('端跳精度max', digits=(6, 1)) cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1)) + cutting_tool_blade_tip_working_size = fields.Char('刀尖处理尺寸(R半径mm/倒角)', size=20) + fit_blade_shape_id = fields.Many2many('maintenance.equipment.image', 'rel_fit_blade_shape_product_template', + '适配刀片形状', domain=[('type', '=', '刀片形状')]) suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image', 'rel_machining_product_template', '适合加工方式', domain=[('type', '=', '加工能力')]) - blade_tip_characteristics_ids = fields.Many2many('maintenance.equipment.image', + blade_tip_characteristics_id = fields.Many2many('maintenance.equipment.image', 'rel_blade_tip_product_template', '刀尖特征', domain=[('type', '=', '刀尖特征')]) handle_type_ids = fields.Many2many('maintenance.equipment.image', 'rel_handle_product_template', '柄部类型', @@ -103,6 +115,215 @@ class ResProductMo(models.Model): '走刀方向', domain=[('type', '=', '走刀方向')]) suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolant_product_template', '适合冷却液', domain=[('type', '=', '冷却液')]) + compaction_way_ids = fields.Many2many('maintenance.equipment.image', 'rel_compaction_product_template', + '压紧方式', domain=[('type', '=', '压紧方式')]) \ + + @api.onchange('cutting_tool_material_id') + def _onchange_cutting_tool_material_id(self): + for item in self: + if item.cutting_tool_material_id.id != item.cutting_tool_model_id.cutting_tool_material_id.id: + item.cutting_tool_model_id = False + item.specification_id = False + item.cutting_tool_type_id = False + item.brand_id = False + item.tool_hardness = False + item.cutting_tool_run_out_accuracy_max = False + item.cutting_tool_run_out_accuracy_min = False + item.materials_type_id = False + item.cutting_tool_blade_type = False + item.cutting_tool_total_length = False + item.cutting_tool_clamping_way = False + item.cutting_tool_blade_diameter = False + item.cutting_tool_shank_length = False + item.cutting_tool_blade_length = False + item.cutting_tool_blade_number = False + item.cutting_tool_neck_length = False + item.cutting_tool_neck_diameter = False + item.cutting_tool_shank_diameter = False + item.cutting_tool_blade_tip_diameter = False + item.cutting_tool_blade_tip_taper = False + item.cutting_tool_blade_helix_angle = False + item.cutting_tool_blade_type = False + item.cutting_tool_pitch = False + item.cutting_tool_blade_width = False + item.cutting_tool_blade_depth = False + item.cutting_tool_cut_depth = False + item.cutting_tool_coarse_medium_fine = False + item.cutting_tool_run_out_accuracy_max = False + item.cutting_tool_run_out_accuracy_min = False + item.cutting_tool_blade_tip_working_size = False + item.fit_blade_shape_id = False + item.suitable_machining_method_ids = False + item.blade_tip_characteristics_id = False + item.handle_type_ids = False + item.cutting_direction_ids = False + item.suitable_coolant_ids = False + item.compaction_way_ids = False + item.cutting_speed_ids = False + item.feed_per_tooth_ids = False + + # def choice(self): + # if self.cutting_tool_type == '整体式刀具': + # tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_integral_tree') + # elif self.cutting_tool_type == '刀片': + # tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_blade_tree') + # elif self.cutting_tool_type == '刀杆': + # tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_cutter_bar_tree') + # elif self.cutting_tool_type == '刀盘': + # tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree') + # elif self.cutting_tool_type == '刀柄': + # tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree') + # else : + # tree_view = self.env.ref('sf_base.view_sf_tool_materials_basic_parameters_tree') + # return { + # 'name': _('规格'), + # 'view_mode': 'list', + # 'view_id': tree_view.id, + # 'type': 'ir.actions.act_window', + # 'res_model': 'sf.tool.materials.basic.parameters', + # 'target': 'new', + # 'domain': [('cutting_tool_type', '=', self.cutting_tool_type), + # ('standard_library_id', '=', self.cutting_tool_model_id.id)], + # } + + @api.onchange('specification_id') + def _onchange_specification(self): + if self.specification_id: + self.cutting_tool_type_id = self.cutting_tool_model_id.cutting_tool_type_id.id + self.brand_id = self.cutting_tool_model_id.brand_id.id + self.tool_hardness = self.cutting_tool_model_id.tool_hardness + self.cutting_tool_blade_type = self.cutting_tool_model_id.blade_type + self.cutting_tool_coarse_medium_fine = self.cutting_tool_model_id.integral_coarse_medium_fine + self.materials_type_id = self.cutting_tool_model_id.material_model_id.id + self.coating_material = self.cutting_tool_model_id.coating_material + if self.cutting_tool_type == '整体式刀具': + self.cutting_tool_total_length = self.specification_id.total_length + self.cutting_tool_run_out_accuracy_max = self.cutting_tool_model_id.integral_run_out_accuracy_max + self.cutting_tool_run_out_accuracy_min = self.cutting_tool_model_id.integral_run_out_accuracy_min + self.cutting_tool_blade_diameter = self.specification_id.blade_diameter + self.cutting_tool_blade_length = self.specification_id.blade_length + self.cutting_tool_blade_number = self.specification_id.blade_number + self.cutting_tool_blade_type = self.cutting_tool_model_id.blade_type + self.cutting_tool_shank_diameter = self.specification_id.handle_diameter + self.cutting_tool_blade_tip_diameter = self.specification_id.blade_tip_diameter + self.cutting_tool_blade_tip_taper = self.specification_id.blade_tip_taper + self.cutting_tool_blade_helix_angle = self.specification_id.blade_helix_angle + self.cutting_tool_pitch = self.specification_id.pitch + self.cutting_tool_blade_width = self.specification_id.blade_width + self.cutting_tool_blade_depth = self.specification_id.blade_depth + self.cutting_tool_cut_depth = self.specification_id.cutting_depth + self.cutting_speed_ids = self.cutting_tool_model_id.cutting_speed_ids + self.feed_per_tooth_ids = [(0, 0, {'product_template_id': product_template.id, + 'cutting_speed': product_template.cutting_speed, + 'machining_method': product_template.machining_method, + 'blade_diameter': product_template.blade_diameter, + 'materials_type_id': product_template.materials_type_id.id}) for + product_template in + self.cutting_tool_model_id.feed_per_tooth_ids.filtered( + lambda r: r.blade_diameter == self.specification_id.blade_diameter)] + elif self.cutting_tool_type == '夹头': + self.cutting_tool_clamping_length = self.specification_id.clamping_length + self.cutting_tool_clamping_tolerance = self.specification_id.clamping_tolerance + self.cutting_tool_clamping_diameter_min = self.specification_id.min_clamping_diameter + self.cutting_tool_clamping_diameter_min = self.specification_id.max_clamping_diameter + self.cutting_tool_clamping_way = self.specification_id.clamping_mode + self.cutting_tool_top_diameter = self.specification_id.top_diameter + self.cutting_tool_outer_diameter = self.specification_id.outer_diameter + self.cutting_tool_inner_diameter = self.specification_id.inner_diameter + self.tool_weight = self.specification_id.weight + self.cutting_tool_jump_accuracy = self.specification_id.run_out_accuracy + self.cutting_tool_max_load_capacity = self.specification_id.max_load_capacity + self.cutting_tool_er_size_model = self.specification_id.er_size_model + self.cutting_tool_handle_ids = self.cutting_tool_model_id.handle_ids + self.cooling_suit_type_ids = self.specification_id.cooling_jacket + elif self.cutting_tool_type == '刀片': + self.cutting_tool_total_length = self.specification_id.total_length + self.tool_length = self.specification_id.length + self.tool_thickness = self.specification_id.thickness + self.tool_width = self.specification_id.width + self.cutting_tool_cut_blade_length = self.specification_id.cutting_blade_length + self.cutting_tool_blade_tip_circular_arc_radius = self.specification_id.blade_tip_circular_arc_radius + self.cutting_tool_blade_tip_height_tolerance = self.specification_id.blade_tip_height_tolerance + self.cutting_tool_inscribed_circle_diameter = self.specification_id.inscribed_circle_diameter + self.cutting_tool_inscribed_circle_tolerance = self.specification_id.inscribed_circle_tolerance + self.cutting_tool_install_aperture_diameter = self.specification_id.install_aperture_diameter + self.cutting_tool_chip_breaker_groove = self.specification_id.chip_breaker_groove + # self.cutting_tool_cut_depth_max = self.specification_id.blade_blade_number + self.cutting_tool_blade_blade_number = self.specification_id.blade_blade_number + self.cutting_tool_blade_width = self.specification_id.blade_width + self.cutting_tool_rear_angle = self.specification_id.relief_angle + self.cutting_tool_main_included_angle = self.specification_id.main_included_angle + self.cutting_tool_top_angle = self.specification_id.top_angle + self.cutting_tool_blade_tip_dip_angle = self.specification_id.blade_tip_dip_angle + self.cutting_tool_side_cutting_edge_angle = self.specification_id.side_cutting_edge_angle + self.cutting_tool_pitch = self.specification_id.pitch + self.cutting_tool_bladed_teeth_model = self.specification_id.blade_teeth_model + self.cutting_tool_thickness_tolerance = self.specification_id.thickness_tolerance + self.cutting_tool_thread_model = self.specification_id.thread_model + self.cutting_tool_thread_num = self.specification_id.thread_num + self.cutting_tool_cutter_bar_ids = self.cutting_tool_model_id.cutter_bar_ids.ids + self.cutting_tool_cutter_pad_ids = self.cutting_tool_model_id.cutter_pad_ids.ids + self.cutting_speed_ids = self.cutting_tool_model_id.cutting_speed_ids + self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids + elif self.cutting_tool_type in ('刀盘', '刀杆'): + self.cutting_tool_total_length = self.specification_id.total_length + self.tool_length = self.specification_id.length + self.tool_thickness = self.specification_id.thickness + self.tool_width = self.specification_id.width + self.cutting_tool_cut_blade_length = self.specification_id.cutting_blade_length + self.cutting_tool_blade_tip_circular_arc_radius = self.specification_id.blade_tip_circular_arc_radius + self.cutting_tool_blade_tip_height_tolerance = self.specification_id.blade_tip_height_tolerance + self.cutting_tool_inscribed_circle_diameter = self.specification_id.inscribed_circle_diameter + self.cutting_tool_inscribed_circle_tolerance = self.specification_id.inscribed_circle_tolerance + self.cutting_tool_install_aperture_diameter = self.specification_id.install_aperture_diameter + self.cutting_tool_chip_breaker_groove = self.specification_id.chip_breaker_groove + # self.cutting_tool_cut_depth_max = self.specification_id.blade_blade_number + self.cutting_tool_blade_blade_number = self.specification_id.blade_blade_number + self.cutting_tool_blade_width = self.specification_id.blade_width + self.cutting_tool_rear_angle = self.specification_id.relief_angle + self.cutting_tool_main_included_angle = self.specification_id.main_included_angle + self.cutting_tool_top_angle = self.specification_id.top_angle + self.cutting_tool_blade_tip_dip_angle = self.specification_id.blade_tip_dip_angle + if self.cutting_tool_type == '刀盘': + self.cutting_tool_blade_length = self.specification_id.blade_length + self.cutting_tool_cutter_head_diameter = self.specification_id.cutter_head_diameter + self.cutting_tool_interface_diameter = self.specification_id.interface_diameter + else: + self.cutting_tool_knife_head_height = self.specification_id.knife_head_height + self.cutting_tool_knife_head_width = self.specification_id.knife_head_width + self.cutting_tool_knife_head_length = self.specification_id.knife_head_length + elif self.cutting_tool_type == '刀柄': + self.cutting_tool_total_length = self.specification_id.total_length + self.cutting_tool_standard_speed = self.specification_id.standard_rotate_speed + self.cutting_tool_speed_max = self.specification_id.speed_max + self.cutting_tool_change_time = self.specification_id.change_time + self.cutting_tool_total_length = self.specification_id.total_length + self.cutting_tool_clamping_diameter_max = self.specification_id.max_clamping_diameter + self.cutting_tool_clamping_diameter_min = self.specification_id.min_clamping_diameter + self.cutting_tool_flange_length = self.specification_id.flange_shank_length + self.cutting_tool_shank_outer_diameter = self.specification_id.handle_external_diameter + self.cutting_tool_shank_inner_diameter = self.specification_id.handle_inside_diameter + self.suitable_machining_method_ids = [(6, 0, + [])] if not self.cutting_tool_model_id.suitable_machining_method_ids else [ + (6, 0, self.cutting_tool_model_id.suitable_machining_method_ids.ids)] + self.blade_tip_characteristics_id = [(6, 0, + [])] if not self.cutting_tool_model_id.blade_tip_characteristics_id else [ + (6, 0, self.cutting_tool_model_id.blade_tip_characteristics_id.ids)] + + self.handle_type_ids = [(6, 0, + [])] if not self.cutting_tool_model_id.handle_type_ids else [ + (6, 0, self.cutting_tool_model_id.handle_type_ids.ids)] + + self.cutting_direction_ids = [(6, 0, + [])] if not self.cutting_tool_model_id.cutting_direction_ids else [ + (6, 0, self.cutting_tool_model_id.cutting_direction_ids.ids)] + + self.suitable_coolant_ids = [(6, 0, + [])] if not self.cutting_tool_model_id.suitable_coolant_ids else [ + (6, 0, self.cutting_tool_model_id.suitable_coolant_ids.ids)] + self.compaction_way_ids = [(6, 0, + [])] if not self.cutting_tool_model_id.compaction_way_ids else [ + (6, 0, self.cutting_tool_model_id.compaction_way_ids.ids)] # @api.constrains('suitable_machining_method_ids') @@ -193,52 +414,91 @@ class ResProductMo(models.Model): cutting_tool_rear_angle = fields.Integer('后角(°)') cutting_tool_main_included_angle = fields.Integer('主偏角(°)') # cutting_tool_material_model_id = fields.Many2one('sf.materials.model', '材料型号') - cutting_tool_nut = fields.Float('配对螺母(mm)') # 适用夹头型号可以多选 cutting_tool_chuck_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='product_cutting_tool_model_handle_chuck_rel', + 'sf.cutting_tool.standard.library', + relation='product_cutting_tool_library_handle_chuck_rel', column1='model_id_1', column2='model_id_2', domain="[('cutting_tool_type', '=', '夹头')]", string='适用夹头型号') # 刀片参数 + cutting_tool_cut_blade_length = fields.Char('切削刃长(mm)', size=20) + cutting_tool_blade_tip_circular_arc_radius = fields.Char('刀尖圆弧半径(mm)', size=20) cutting_tool_top_angle = fields.Integer('顶角(°)') - cutting_tool_jump_accuracy = fields.Float('径跳精度(mm)') + cutting_tool_inscribed_circle_diameter = fields.Char('内接圆直径(mm)', size=20) + cutting_tool_install_aperture_diameter = fields.Char('安装孔直径(mm)', size=20) + cutting_tool_chip_breaker_groove = fields.Selection([('无', '无'), ('单面', '单面'), ('双面', '双面')], + string='有无断屑槽') + cutting_tool_bladed_teeth_model = fields.Selection( + [('无', '无'), ('V牙型', 'V牙型'), ('米制全牙型', '米制全牙型'), ('美制全牙型', '美制全牙型'), + ('惠氏全牙型', '惠氏全牙型'), ('BSPT全牙型', 'BSPT全牙型'), ('NPT全牙型', 'NPT全牙型'), + ('UNJ全牙型', 'UNJ全牙型'), ('DIN405圆牙型', 'DIN405圆牙型'), ('ACME梯形', 'ACME梯形'), + ('石油管螺纹刀片', '石油管螺纹刀片'), ('矮牙ACME梯形', '矮牙ACME梯形'), + ('Trapeze30° 103', 'Trapeze30° 103')], string='刀片牙型', default='无') + cutting_tool_blade_blade_number = fields.Selection( + [('0', '0'), ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), + ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10')], + string='刀片的刃数(个)') + + cutting_tool_blade_tip_dip_angle = fields.Integer('刀尖倾角(°)') + cutting_tool_side_cutting_edge_angle = fields.Integer('侧切削角(°)') + cutting_tool_thread_model = fields.Selection([('无', '无'), ('外螺纹', '外螺纹'), ('内螺纹', '内螺纹')], + string='螺纹类型') + cutting_tool_thread_num = fields.Char('每英寸螺纹数(tpi)', size=20) + cutting_tool_blade_tip_height_tolerance = fields.Char('刀尖高度公差(mm)', size=20) + cutting_tool_inscribed_circle_tolerance = fields.Char('内接圆公差(mm)', size=20) + cutting_tool_thickness_tolerance = fields.Char('厚度公差(mm)', size=20) + + cutting_tool_jump_accuracy = fields.Char('径跳精度(mm)') cutting_tool_working_hardness = fields.Char('加工硬度(hrc)') cutting_tool_cutter_bar_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='product_cutting_tool_model_blade_cutter_bar_rel', + 'sf.cutting_tool.standard.library', + relation='product_cutting_tool_library_cutter_bar_rel', column1='model_id_1', column2='model_id_2', domain="[('cutting_tool_type', '=', '刀杆')]", string='适用刀杆型号' ) cutting_tool_cutter_pad_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='product_cutting_tool_model_blade_cutter_pad_rel', + 'sf.cutting_tool.standard.library', + relation='product_cutting_tool_library_cutter_pad_rel', column1='model_id_1', column2='model_id_2', domain="[('cutting_tool_type', '=', '刀盘')]", string='适用刀盘型号' # 使用空列表作为默认值 ) # 刀杆/参数 + cutting_tool_knife_head_height = fields.Float('刀头高度(mm)') + cutting_tool_knife_head_width = fields.Float('刀头宽度(mm)') + cutting_tool_knife_head_length = fields.Float('刀头长度(mm)') cutting_tool_blade_diameter = fields.Float('刃径/刃部直径(mm)') + cutting_tool_cutter_arbor_diameter = fields.Char('刀杆直径(mm)', size=20) + cutting_tool_min_machining_aperture = fields.Char('最小加工孔径(mm)', size=20) + cutting_tool_install_blade_tip_num = fields.Char('可装刀片数/齿数(个)', size=20) + cutting_tool_installing_structure = fields.Char('安装结构', size=20) cutting_tool_blade_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='product_cutting_tool_model_pad_blade_rel', + 'sf.cutting_tool.standard.library', + relation='product_cutting_tool_library_pad_blade_rel', column1='model_id_1', column2='model_id_2', domain="[('cutting_tool_type', '=', '刀片')]", string='适用刀片型号' # 使用空列表作为默认值 ) - cutting_tool_wrench = fields.Float('配对扳手(mm)') - # cutting_tool_screw = fields.Float('配备螺丝(mm)') - cutting_tool_accuracy_level = fields.Char('精度等级') + cutting_tool_tool_shim = fields.Char('适配刀垫型号', size=50) + cutting_tool_cotter_pin = fields.Char('适配销钉型号', size=50) + cutting_tool_pressing_plate = fields.Char('适配压板型号', size=50) + cutting_tool_screw = fields.Char('适配螺钉型号', size=50) + cutting_tool_wrench = fields.Char('适配扳手型号') + cutting_tool_is_cooling_hole = fields.Boolean('有无冷却孔', default=False) + cutting_tool_locating_slot_code = fields.Char('定位槽代号', size=20) + # 刀盘参数 + cutting_tool_cutter_head_diameter = fields.Char('刀盘直径(mm)', size=20) + cutting_tool_interface_diameter = fields.Char('接口直径(mm)', size=20) + # 刀柄参数 - cutting_tool_head_diameter = fields.Float('头部直径') - cutting_tool_diameter_max = fields.Float('最大直径(mm)') - cutting_tool_clamping_diameter = fields.Float('夹持直径(mm)') + cutting_tool_shank_outer_diameter = fields.Float('柄部外径(mm)') + cutting_tool_shank_inner_diameter = fields.Float('柄部内径(mm)') cutting_tool_clamping_length = fields.Float('夹持长度(mm)') cutting_tool_clamping_tolerance = fields.Float('夹持公差(mm)') cutting_tool_clamping_diameter_max = fields.Float('最大夹持直径') @@ -248,34 +508,30 @@ class ResProductMo(models.Model): cutting_tool_is_rough_finish = fields.Boolean('可粗加工', default=False) cutting_tool_is_finish = fields.Boolean('可精加工', default=False) cutting_tool_is_drill_hole = fields.Boolean('可钻孔', default=False) - cutting_tool_is_safety_lock = fields.Boolean('安全锁', default=False) + cutting_tool_is_safety_lock = fields.Boolean('有无安全锁', default=False) cutting_tool_is_high_speed_cutting = fields.Boolean('可高速切削', default=False) - cutting_tool_dynamic_balance_class = fields.Char('动平衡等级') cutting_tool_change_time = fields.Integer('换刀时间(s)') cutting_tool_clamping_way = fields.Char('夹持方式') - cutting_tool_standard_speed = fields.Integer('标准转速(n/min)') + cutting_tool_standard_speed = fields.Char('标准转速(n/min)') cutting_tool_speed_max = fields.Integer('最大转速(n/min)') cutting_tool_cooling_type = fields.Char('冷却类型') - cutting_tool_body_accuracy = fields.Float('本体精度(mm)') - apply_lock_nut_model = fields.Char('适用锁紧螺母型号') - apply_lock_wrench_model = fields.Char('适用锁紧扳手型号') - cutting_tool_detection_accuracy_max = fields.Float('最大检测精度(mm)') - cutting_tool_detection_accuracy_min = fields.Float('最小检测精度(mm)') # 夹头参数 cutting_tool_taper = fields.Integer('锥度(°)') + cutting_tool_top_diameter = fields.Float('顶部直径') cutting_tool_outer_diameter = fields.Float('外径(mm)') cutting_tool_inner_diameter = fields.Float('内径(mm)') cooling_suit_type_ids = fields.Char('适用冷却套型号') - # cooling_suit_type_ids = fields.Many2many('冷却类型') + cutting_tool_max_load_capacity = fields.Char('最大负载能力(kg)') cutting_tool_er_size_model = fields.Char('ER尺寸型号') cutting_tool_handle_ids = fields.Many2many( - 'sf.cutting.tool.model', - relation='product_cutting_tool_model_chuck_handle_rel', + 'sf.cutting_tool.standard.library', + relation='product_cutting_tool_library_chuck_handle_rel', column1='model_id_1', column2='model_id_2', domain="[('cutting_tool_type', '=', '刀柄')]", string='适用刀柄型号' ) + # 夹具参数 fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料") fixture_model_id = fields.Many2one('sf.fixture.model', string="夹具型号") @@ -404,12 +660,6 @@ class ResProductMo(models.Model): self.detailed_type = 'product' self.sale_ok = False - @api.onchange('cutting_tool_material_id') - def _onchange_cutting_tool_material_id(self): - for item in self: - if item.cutting_tool_material_id.id != item.cutting_tool_model_id.cutting_tool_material_id.id: - item.cutting_tool_model_id = False - @api.onchange('fixture_material_id') def _onchange_fixture_material_id(self): for item in self: @@ -446,119 +696,6 @@ class ResProductMo(models.Model): item.fixture_apply_machine_tool_type_ids = self._get_ids( item.fixture_model_id.apply_machine_tool_type_ids) - # @api.onchange('cutting_tool_model_id') - # def _onchange_cutting_tool_model_id(self): - # for item in self: - # if self.cutting_tool_type is not False: - # item.brand_id = item.cutting_tool_model_id.brand_id.id - # item.cutting_tool_type_id = item.cutting_tool_model_id.cutting_tool_type_id.id - # item.tool_length = item.cutting_tool_model_id.tool_length - # item.tool_width = item.cutting_tool_model_id.tool_width - # item.tool_height = item.cutting_tool_model_id.tool_height - # item.tool_thickness = item.cutting_tool_model_id.tool_thickness - # item.tool_weight = item.cutting_tool_model_id.tool_weight - # item.coating_material = item.cutting_tool_model_id.coating_material - # item.cutting_tool_total_length = item.cutting_tool_model_id.total_length - # item.cutting_tool_shank_length = item.cutting_tool_model_id.shank_length - # item.cutting_tool_neck_length = item.cutting_tool_model_id.cutting_tool_neck_length - # item.cutting_tool_shank_diameter = item.cutting_tool_model_id.cutting_tool_shank_diameter - # item.cutting_tool_blade_diameter = item.cutting_tool_model_id.cutting_tool_blade_diameter - # item.cutting_tool_neck_diameter = item.cutting_tool_model_id.cutting_tool_neck_diameter - # item.cutting_tool_blade_tip_diameter = item.cutting_tool_model_id.cutting_tool_blade_tip_diameter - # item.cutting_tool_blade_tip_taper = item.cutting_tool_model_id.cutting_tool_blade_tip_taper - # item.cutting_tool_blade_helix_angle = item.cutting_tool_model_id.cutting_tool_blade_helix_angle - # item.cutting_tool_blade_type = item.cutting_tool_model_id.cutting_tool_blade_type - # item.cutting_tool_coarse_medium_fine = item.cutting_tool_model_id.cutting_tool_coarse_medium_fine - # item.tool_hardness = item.cutting_tool_model_id.tool_hardness - # item.cutting_tool_run_out_accuracy_max = item.cutting_tool_model_id.cutting_tool_run_out_accuracy_max - # item.cutting_tool_run_out_accuracy_min = item.cutting_tool_model_id.cutting_tool_run_out_accuracy_min - # item.suitable_machining_method_ids = self._get_ids( - # item.cutting_tool_model_id.suitable_machining_method_ids) - # item.blade_tip_characteristics_ids = self._get_ids( - # item.cutting_tool_model_id.blade_tip_characteristics_ids) - # item.handle_type_ids = self._get_ids(item.cutting_tool_model_id.handle_type_ids) - # item.cutting_direction_ids = self._get_ids(item.cutting_tool_model_id.cutting_direction_ids) - # item.suitable_coolant_ids = self._get_ids(item.cutting_tool_model_id.suitable_coolant_ids) - # item.cutting_tool_diameter = item.cutting_tool_model_id.diameter - # item.cutting_tool_blade_number = item.cutting_tool_model_id.blade_number - # item.cutting_tool_front_angle = item.cutting_tool_model_id.front_angle - # item.cutting_tool_rear_angle = item.cutting_tool_model_id.rear_angle - # item.cutting_tool_main_included_angle = item.cutting_tool_model_id.main_included_angle - # item.materials_type_id = item.cutting_tool_model_id.material_model_id.id - # item.cutting_tool_nut = item.cutting_tool_model_id.nut - # item.cutting_tool_top_angle = item.cutting_tool_model_id.top_angle - # item.cutting_tool_jump_accuracy = item.cutting_tool_model_id.jump_accuracy - # item.cutting_tool_working_hardness = item.cutting_tool_model_id.working_hardness - # item.cutting_tool_blade_diameter = item.cutting_tool_model_id.blade_diameter - # item.cutting_tool_wrench = item.cutting_tool_model_id.wrench - # # item.cutting_tool_screw = item.cutting_tool_model_id.screw - # item.cutting_tool_accuracy_level = item.cutting_tool_model_id.accuracy_level - # item.cutting_tool_diameter_max = item.cutting_tool_model_id.diameter_max - # item.cutting_tool_clamping_diameter = item.cutting_tool_model_id.clamping_diameter - # item.cutting_tool_flange_length = item.cutting_tool_model_id.flange_length - # item.cutting_tool_flange_diameter = item.cutting_tool_model_id.flange_diameter - # item.cutting_tool_outer_diameter = item.cutting_tool_model_id.outer_diameter - # item.cutting_tool_inner_diameter = item.cutting_tool_model_id.inner_diameter - # item.cutting_tool_chuck_ids = self._get_ids(item.cutting_tool_model_id.chuck_ids) - # item.cutting_tool_cutter_bar_ids = self._get_ids(item.cutting_tool_model_id.cutter_bar_ids) - # item.cutting_tool_cutter_pad_ids = self._get_ids(item.cutting_tool_model_id.cutter_pad_ids) - # item.cutting_tool_blade_ids = self._get_ids(item.cutting_tool_model_id.blade_ids) - # item.cutting_tool_handle_ids = self._get_ids(item.cutting_tool_model_id.handle_ids) - # else: - # item.brand_id = False - # item.cutting_tool_type_id = False - # item.brand_id = False - # item.tool_length = False - # item.tool_width = False - # item.tool_height = False - # item.tool_thickness = False - # item.tool_weight = False - # item.coating_material = False - # item.cutting_tool_total_length = False - # item.cutting_tool_shank_length = False - # item.cutting_tool_blade_length = False - # item.cutting_tool_neck_length = False - # item.cutting_tool_shank_diameter = False - # item.cutting_tool_blade_diameter = False - # item.cutting_tool_neck_diameter = False - # item.cutting_tool_blade_tip_diameter = False - # item.cutting_tool_blade_tip_taper = False - # item.cutting_tool_blade_helix_angle = False - # item.cutting_tool_blade_type = False - # item.cutting_tool_coarse_medium_fine = False - # item.tool_hardness = False - # item.cutting_tool_run_out_accuracy_max = False - # item.cutting_tool_run_out_accuracy_min = False - # item.suitable_machining_method_ids = False - # item.blade_tip_characteristics_ids = False - # item.handle_type_ids = False - # item.cutting_direction_ids = False - # item.suitable_coolant_ids = False - # item.cutting_tool_diameter = False - # item.cutting_tool_blade_number = False - # item.cutting_tool_front_angle = False - # item.cutting_tool_rear_angle = False - # item.cutting_tool_main_included_angle = False - # item.materials_type_id = False - # item.cutting_tool_nut = False - # item.cutting_tool_top_angle = False - # item.cutting_tool_jump_accuracy = False - # item.cutting_tool_working_hardness = False - # item.cutting_tool_blade_diameter = False - # item.cutting_tool_wrench = False - # # item.cutting_tool_screw = False - # item.cutting_tool_accuracy_level = False - # item.cutting_tool_diameter_max = False - # item.cutting_tool_clamping_diameter = False - # item.cutting_tool_flange_length = False - # item.cutting_tool_flange_diameter = False - # item.cutting_tool_outer_diameter = False - # item.cutting_tool_inner_diameter = False - # item.cutting_tool_chuck_ids = False - # item.cutting_tool_cutter_bar_ids = False - # item.cutting_tool_cutter_pad_ids = False - # item.cutting_tool_blade_ids = False - # item.cutting_tool_handle_ids = False 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') @@ -736,9 +873,9 @@ class ResProductMo(models.Model): # 将attach的datas内容转为glb文件 def transition_glb_file(self, report_path, code): - shapes = read_step_file(report_path) + # shapes = read_step_file(report_path) output_file = os.path.join('/tmp', str(code) + '.stl') - write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) + # write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) # 转化为glb output_glb_file = os.path.join('/tmp', str(code) + '.glb') util_path = get_resource_path('sf_dlm', 'static/util') @@ -783,6 +920,7 @@ class ResMrpBomMo(models.Model): # 坯料BOM组件:选取当前坯料原材料, # 然后根据当前的坯料的体积得出需要的原材料重量(立方米m³) *材料密度 * 1000 = 所需原材料重量KG(公斤) # 坯料所需原材料公式:当前的坯料的体积(立方米m³) *材料密度 * 1000 = 所需原材料重量KG(公斤) + def bom_create_line(self, embryo): # 选取当前坯料原材料 raw_bom_line = self.get_raw_bom(embryo) @@ -801,7 +939,6 @@ class ResMrpBomMo(models.Model): else: return False - # 查询材料型号默认排第一的供应商 def get_supplier(self, materials_type): @@ -862,7 +999,8 @@ class SfMaintenanceEquipmentTool(models.Model): _description = '机床刀位' equipment_id = fields.Many2one('maintenance.equipment', string='设备') - product_template_id = fields.Many2one('product.template', string='功能刀具名称', domain="[('categ_type', '=', '刀具')]") + product_template_id = fields.Many2one('product.template', string='功能刀具名称', + domain="[('categ_type', '=', '刀具')]") image_1920 = fields.Binary('图片', related='product_template_id.image_1920') categ_type = fields.Char(string='功能刀具类型') diameter = fields.Char('直径') @@ -874,4 +1012,3 @@ class SfMaintenanceEquipmentTool(models.Model): alarm_value = fields.Char('报警值') used_value = fields.Char('已使用值') code = fields.Char('机床刀位号') - diff --git a/sf_manufacturing/models/tool_other_features.py b/sf_manufacturing/models/tool_other_features.py deleted file mode 100644 index 03a954f9..00000000 --- a/sf_manufacturing/models/tool_other_features.py +++ /dev/null @@ -1,249 +0,0 @@ -from odoo import fields, models, api - - -class SuitableMachiningMethod(models.Model): - _name = 'sf.suitable.machining.method' - _description = '适合加工方式' - - name = fields.Char('名称') - image = fields.Image('图片') - - @api.model - def name_search(self, name='', args=None, operator='ilike', limit=100): - # 调用父类的name_search方法,获取原始的结果列表 - res = super().name_search(name, args, operator, limit) - # 定义一个空字典用来存储id和name的映射关系 - name_dict = {} - # 遍历结果列表,将id和name存入字典中 - for item in res: - id = item[0] - name = item[1] - name_dict[id] = name - # 根据id列表搜索符合条件的记录 - records = self.browse(name_dict.keys()) - # 定义一个新的结果列表用来存储修改后的结果 - new_res = [] - # 遍历每条记录 - for record in records: - # 获取记录的id,name和image属性 - id = record.id - name = name_dict[id] - image = record.image - # 如果image不为空,将其转换为data URI scheme - if image: - data_uri = f"data:image/png;base64,{image.decode('utf-8')}" - else: - data_uri = "" - # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result - new_res.append([id, name, data_uri]) - # 返回新的结果列表 - return new_res - - -class BladeTipCharacteristics(models.Model): - _name = 'sf.blade.tip.characteristics' - _description = '刀尖特征' - - name = fields.Char('名称') - image = fields.Image('图片') - - @api.model - def name_search(self, name='', args=None, operator='ilike', limit=100): - # 调用父类的name_search方法,获取原始的结果列表 - res = super().name_search(name, args, operator, limit) - # 定义一个空字典用来存储id和name的映射关系 - name_dict = {} - # 遍历结果列表,将id和name存入字典中 - for item in res: - id = item[0] - name = item[1] - name_dict[id] = name - # 根据id列表搜索符合条件的记录 - records = self.browse(name_dict.keys()) - # 定义一个新的结果列表用来存储修改后的结果 - new_res = [] - # 遍历每条记录 - for record in records: - # 获取记录的id,name和image属性 - id = record.id - name = name_dict[id] - image = record.image - # 如果image不为空,将其转换为data URI scheme - if image: - data_uri = f"data:image/png;base64,{image.decode('utf-8')}" - else: - data_uri = "" - # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result - new_res.append([id, name, data_uri]) - # 返回新的结果列表 - return new_res - - -class HandleType(models.Model): - _name = 'sf.handle.type' - _description = '柄部类型' - - name = fields.Char('名称') - image = fields.Image('图片') - - @api.model - def name_search(self, name='', args=None, operator='ilike', limit=100): - # 调用父类的name_search方法,获取原始的结果列表 - res = super().name_search(name, args, operator, limit) - # 定义一个空字典用来存储id和name的映射关系 - name_dict = {} - # 遍历结果列表,将id和name存入字典中 - for item in res: - id = item[0] - name = item[1] - name_dict[id] = name - # 根据id列表搜索符合条件的记录 - records = self.browse(name_dict.keys()) - # 定义一个新的结果列表用来存储修改后的结果 - new_res = [] - # 遍历每条记录 - for record in records: - # 获取记录的id,name和image属性 - id = record.id - name = name_dict[id] - image = record.image - # 如果image不为空,将其转换为data URI scheme - if image: - data_uri = f"data:image/png;base64,{image.decode('utf-8')}" - else: - data_uri = "" - # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result - new_res.append([id, name, data_uri]) - # 返回新的结果列表 - return new_res - - -class CuttingDirection(models.Model): - _name = 'sf.cutting.direction' - _description = '走刀方向' - - name = fields.Char('名称') - image = fields.Image('图片') - - @api.model - def name_search(self, name='', args=None, operator='ilike', limit=100): - # 调用父类的name_search方法,获取原始的结果列表 - res = super().name_search(name, args, operator, limit) - # 定义一个空字典用来存储id和name的映射关系 - name_dict = {} - # 遍历结果列表,将id和name存入字典中 - for item in res: - id = item[0] - name = item[1] - name_dict[id] = name - # 根据id列表搜索符合条件的记录 - records = self.browse(name_dict.keys()) - # 定义一个新的结果列表用来存储修改后的结果 - new_res = [] - # 遍历每条记录 - for record in records: - # 获取记录的id,name和image属性 - id = record.id - name = name_dict[id] - image = record.image - # 如果image不为空,将其转换为data URI scheme - if image: - data_uri = f"data:image/png;base64,{image.decode('utf-8')}" - else: - data_uri = "" - # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result - new_res.append([id, name, data_uri]) - # 返回新的结果列表 - return new_res - - -class SuitableCoolant(models.Model): - _name = 'sf.suitable.coolant' - _description = '适合冷却液' - - name = fields.Char('名称') - image = fields.Image('图片') - - @api.model - def name_search(self, name='', args=None, operator='ilike', limit=100): - # 调用父类的name_search方法,获取原始的结果列表 - res = super().name_search(name, args, operator, limit) - # 定义一个空字典用来存储id和name的映射关系 - name_dict = {} - # 遍历结果列表,将id和name存入字典中 - for item in res: - id = item[0] - name = item[1] - name_dict[id] = name - # 根据id列表搜索符合条件的记录 - records = self.browse(name_dict.keys()) - # 定义一个新的结果列表用来存储修改后的结果 - new_res = [] - # 遍历每条记录 - for record in records: - # 获取记录的id,name和image属性 - id = record.id - name = name_dict[id] - image = record.image - # 如果image不为空,将其转换为data URI scheme - if image: - data_uri = f"data:image/png;base64,{image.decode('utf-8')}" - else: - data_uri = "" - # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result - new_res.append([id, name, data_uri]) - # 返回新的结果列表 - return new_res - - -class CuttingSpeed(models.Model): - _name = 'sf.cutting.speed' - _description = '切削速度Vc' - - # def _get_order(self): - # last_tool = self.search([], order='id desc', limit=1) - # if last_tool: - # last_order = int(last_tool.order) - # new_order = last_order + 1 - # else: - # new_order = '1' - # return new_order - # - # order = fields.Char('序', default=_get_order, readonly=True) - - product_template_id = fields.Many2one('product.template', string='产品') - - execution_standard_id = fields.Char('执行标准') - material_code = fields.Char('材料代号') - material_name = fields.Char('材料名称') - material_grade = fields.Char('材料牌号') - tensile_strength = fields.Float('拉伸强度 (N/mm²)') - hardness = fields.Float('硬度(HRC)') - - cutting_speed_n1 = fields.Char('径向切宽 ae=100%D1 ap=1*D1 切削速度Vc') - cutting_speed_n2 = fields.Char('径向切宽 ae=50%D1 ap=1.5*D1 切削速度Vc') - cutting_speed_n3 = fields.Char('径向切宽 ae=25%D1 ap=L1max 切削速度Vc') - cutting_speed_n4 = fields.Char('径向切宽 ae=15%D1 ap=L1max 切削速度Vc') - cutting_speed_n5 = fields.Char('径向切宽 ae=5%D1 ap=L1max 切削速度Vc') - rough_machining = fields.Char('粗加工 Vc(m/min)') - precision_machining = fields.Char('精加工 Vc(m/min)') - application = fields.Selection([('主应用', '主应用'), ('次应用', '次应用')], '主/次应用') - - -class FeedPerTooth(models.Model): - _name = 'sf.feed.per.tooth' - _description = '每齿走刀量fz' - - product_template_id = fields.Many2one('product.template', string='产品') - - cutting_speed = fields.Char('径向切宽 ae(mm)') - machining_method = fields.Selection([('直铣', '直铣'), ('坡铣', '坡铣')], string='加工方式') - materials_type_id = fields.Many2one('sf.materials.model', string='材料型号') - blade_diameter = fields.Float('刃部直径D1(mm)', readonly=True, related='product_template_id.cutting_tool_blade_diameter') - feed_per_tooth = fields.Char('每齿走刀量 (mm/z)') - unit = fields.Char('单位', default='fz') - - # @api.depends('product_template_id') - # def _compute_product_template_id(self): - # if self.product_template_id is not None: - # self.blade_diameter = self.product_template_id.cutting_tool_blade_diameter diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index 66de9496..a3c4e2a9 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -4,16 +4,9 @@ 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 - access_sf_production_line,sf.production.line,model_sf_production_line,base.group_user,1,1,1,1 - -access_sf_suitable_machining_method,sf_suitable_machining_method,model_sf_suitable_machining_method,base.group_user,1,1,1,1 -access_sf_blade_tip_characteristics,sf_blade_tip_characteristics,model_sf_blade_tip_characteristics,base.group_user,1,1,1,1 -access_sf_handle_type,sf_handle_type,model_sf_handle_type,base.group_user,1,1,1,1 -access_sf_cutting_direction,sf_cutting_direction,model_sf_cutting_direction,base.group_user,1,1,1,1 -access_sf_suitable_coolant,sf_suitable_coolant,model_sf_suitable_coolant,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 access_maintenance_equipment_tool,maintenance_equipment_tool,model_maintenance_equipment_tool,base.group_user,1,1,1,1 + + diff --git a/sf_manufacturing/views/tool_other_features_view.xml b/sf_manufacturing/views/tool_other_features_view.xml deleted file mode 100644 index 952f7bc8..00000000 --- a/sf_manufacturing/views/tool_other_features_view.xml +++ /dev/null @@ -1,231 +0,0 @@ - - - - - 适合加工方式 - sf.suitable.machining.method - - - - - - - - - - 适合加工方式 - sf.suitable.machining.method - -
- - - - - - -
-
-
- - - 适合加工方式 - ir.actions.act_window - sf.suitable.machining.method - tree,form - - - - - - 刀尖特征 - sf.blade.tip.characteristics - - - - - - - - - - 刀尖特征 - sf.blade.tip.characteristics - -
- - - - - - -
-
-
- - - 刀尖特征 - ir.actions.act_window - sf.blade.tip.characteristics - tree,form - - - - - - 柄部类型 - sf.handle.type - - - - - - - - - - 柄部类型 - sf.handle.type - -
- - - - - - -
-
-
- - - 柄部类型 - ir.actions.act_window - sf.handle.type - tree,form - - - - - - 走刀方向 - sf.cutting.direction - - - - - - - - - - 走刀方向 - sf.cutting.direction - -
- - - - - - -
-
-
- - - 走刀方向 - ir.actions.act_window - sf.cutting.direction - tree,form - - - - - - 适合冷却液 - sf.suitable.coolant - - - - - - - - - - 适合冷却液 - sf.suitable.coolant - -
- - - - -
-
-
- - - 适合冷却液 - ir.actions.act_window - sf.suitable.coolant - tree,form - - - - - - 切削速度Vc - sf.cutting.speed - - - - - - - - - - - - - - - - - - - - - - - 切削速度Vc - ir.actions.act_window - sf.cutting.speed - tree - - - - - - 每齿走刀量fz - sf.feed.per.tooth - - - - - - - - - - - - - - 每齿走刀量fz - ir.actions.act_window - sf.feed.per.tooth - tree - -
\ No newline at end of file diff --git a/sf_mrs_connect/__manifest__.py b/sf_mrs_connect/__manifest__.py index b1955012..3ccd3ac4 100644 --- a/sf_mrs_connect/__manifest__.py +++ b/sf_mrs_connect/__manifest__.py @@ -13,6 +13,7 @@ 'depends': ['sf_base', 'base_setup'], 'data': [ 'data/ir_cron_data.xml', + 'security/ir.model.access.csv', 'views/res_config_settings_views.xml' ], 'demo': [ diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index 142dca7d..91bd52c6 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -21,53 +21,50 @@ class ResConfigSettings(models.TransientModel): def sf_all_sync(self): try: + self.env['sf.production.materials'].sync_all_production_materials() + _logger.info("同步资源库材料完成") + self.env['sf.materials.model'].sync_all_materials_model() + _logger.info("同步资源库材料型号完成") self.env['sf.international.standards'].sync_all_mrs_international_standards() _logger.info("同步资源库国际标准完成") self.env['material.apply'].sync_all_material_apply() _logger.info("同步资源库材料应用完成") - self.env['sf.production.materials'].sync_all_production_materials() - _logger.info("同步资源库材料") - self.env['sf.materials.model'].sync_all_materials_model() - _logger.info("同步资源库材料型号") self.env['sf.production.process.category'].sync_all_production_process_category() - _logger.info("同步资源库表面工艺类别") + _logger.info("同步资源库表面工艺类别完成") self.env['sf.production.process'].sync_all_production_process() - _logger.info("同步资源库表面工艺") + _logger.info("同步资源库表面工艺完成") # self.env['sf.processing.technology'].sync_all_processing_technology() # _logger.info("同步资源库加工工艺") self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags() - _logger.info("同步资源库品牌类别") + _logger.info("同步资源库品牌类别完成") self.env['sf.machine.brand'].sync_all_machine_brand() - _logger.info("同步资源库品牌") + _logger.info("同步资源库品牌完成") self.env['sf.machine.control_system'].sync_all_machine_control_system() - _logger.info("同步资源库控制系统") + _logger.info("同步资源库控制系统完成") self.env['sf.machine_tool.category'].sync_all_machine_tool_category() - _logger.info("同步资源库机床类型") + _logger.info("同步资源库机床类型完成") self.env['sf.production.process.parameter'].sync_all_production_process_parameter() - _logger.info("同步刀具物料") + _logger.info("同步刀具物料完成") self.env['sf.cutting.tool.material'].sync_all_cutting_tool_material() - _logger.info("同步刀具类型") + _logger.info("同步刀具类型完成") self.env['sf.cutting.tool.type'].sync_all_tool_type() - _logger.info("同步所有刀具类型完成") - # _logger.info("同步所有刀具型号...") - # self.env['sf.cutting.tool.model'].sync_all_tool_model() - _logger.info("同步所有刀具型号完成") + _logger.info("同步功能刀具类型完成") self.env['sf.functional.cutting.tool.model'].sync_all_functional_cutting_tool_model() - _logger.info("同步夹具物料") + _logger.info("同步夹具物料完成") self.env['sf.fixture.material'].sync_all_fixture_material() - _logger.info("同步联装类型") + _logger.info("同步联装类型完成") self.env['sf.multi_mounting.type'].sync_all_multi_mounting_type() - _logger.info("同步夹具型号") + _logger.info("同步夹具型号完成") self.env['sf.fixture.model'].sync_all_fixture_model() - _logger.info("同步功能夹具类型") - # self.env['sf.functional.fixture'].sync_all_functional_fixture() - + _logger.info("同步夹具型号类型完成") self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type() - + _logger.info("同步功能夹具类型完成") self.env['sf.machine_tool.type'].sync_all_machine_tool_type() _logger.info("同步资源库机床型号完成") self.env['maintenance.equipment.image'].sync_all_maintenance_equipment_image() - _logger.info("同步能力特征库") + _logger.info("同步能力特征库完成") + self.env['sf.cutting_tool.standard.library'].sync_all_cutting_tool_standard_library() + _logger.info("同步刀具标准库完成") except Exception as e: _logger.info("捕获错误信息:%s" % e) raise ValidationError("数据错误导致同步失败,请联系管理员") diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index a326d024..6d5a819c 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -32,7 +32,7 @@ class MrStaticResourceDataSync(models.Model): # logging.info("材料型号已每日同步成功") # self.env['mrs.international.standards']._cron_mrs_international_standards_func() # logging.info("材料型号材料应用已每日同步成功") - # self.env['material.apply']._cron_material_apply_func() + self.env['material.apply']._cron_material_apply_func() logging.info("材料型号材料应用已每日同步成功") self.env['sf.production.process.category'].sync_production_process_category_yesterday() logging.info("表面工艺类别已每日同步成功") @@ -60,6 +60,8 @@ class MrStaticResourceDataSync(models.Model): logging.info("功能刀具类型已每日同步成功") self.env['maintenance.equipment.image'].sync_maintenance_equipment_image_yesterday() logging.info("能力特征库已每日同步成功") + self.env['sf.cutting_tool.standard.library'].sync_cutting_tool_standard_library_yesterday() + logging.info("刀具标准库已每日同步成功") except Exception as e: logging.info("捕获错误信息:%s" % e) raise ValidationError("数据错误导致同步失败,请联系管理员") @@ -73,11 +75,9 @@ class sfProductionMaterials(models.Model): # 定时同步每日材料 def sync_production_materials_yesterday(self): # 配置中获取token - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -101,11 +101,9 @@ class sfProductionMaterials(models.Model): # 同步所有材料 def sync_all_production_materials(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -135,11 +133,9 @@ class sfMaterialModel(models.Model): # 定时同步每日材料型号 def sync_materials_model_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -183,11 +179,9 @@ class sfMaterialModel(models.Model): # 同步所有材料型号 def sync_all_materials_model(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -245,11 +239,9 @@ class sfProductionProcessCategory(models.Model): # 定时同步每日表面工艺类别 def sync_production_process_category_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -272,11 +264,9 @@ class sfProductionProcessCategory(models.Model): # 同步所有表面工艺类别 def sync_all_production_process_category(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -304,11 +294,9 @@ class sfProductionProcess(models.Model): # 定时同步每日表面工艺 def sync_production_process_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -347,11 +335,9 @@ class sfProductionProcess(models.Model): # 同步所有表面工艺 def sync_all_production_process(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -378,7 +364,6 @@ class sfProductionProcess(models.Model): raise ValidationError("表面工艺认证未通过") - class sfProcessingTechnology(models.Model): _inherit = 'sf.processing.technology' _description = '加工工艺' @@ -386,11 +371,9 @@ class sfProcessingTechnology(models.Model): # 定时同步加工工艺 def sync_processing_technology_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -414,11 +397,9 @@ class sfProcessingTechnology(models.Model): # 同步所有加工工艺 def sync_all_processing_technology(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -448,11 +429,9 @@ class MachineBrandTags(models.Model): # 定时同步品牌类别 def sync_machine_brand_tags_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -472,12 +451,9 @@ class MachineBrandTags(models.Model): # 同步所有品牌类别 def sync_all_machine_brand_tags(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -503,11 +479,9 @@ class MachineControlSystem(models.Model): # 定时同步控制系统 def sync_machine_control_system_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -534,11 +508,9 @@ class MachineControlSystem(models.Model): # 同步所有控制系统 def sync_all_machine_control_system(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -571,11 +543,9 @@ class MachineBrand(models.Model): # 定时同步品牌 def sync_machine_brand_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -602,11 +572,9 @@ class MachineBrand(models.Model): # 同步所有品牌 def sync_all_machine_brand(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -639,11 +607,9 @@ class MachineToolType(models.Model): # 定时同步机床型号 def sync_machine_tool_type_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -744,11 +710,9 @@ class MachineToolType(models.Model): # 同步所有机床型号 def sync_all_machine_tool_type(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -857,11 +821,9 @@ class sfProcessingOrder(models.Model): # 定时同步工序 def sync_processing_order_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -879,11 +841,9 @@ class sfProcessingOrder(models.Model): # 同步所有工序 def sync_all_processing_order(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -907,11 +867,9 @@ class sfProductionProcessParameter(models.Model): # 定时同步每日表面工艺可选参数 def sync_production_process_parameter_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -941,25 +899,20 @@ class sfProductionProcessParameter(models.Model): # 同步所有表面工艺可选参数 def sync_all_production_process_parameter(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: - _logger.info('result:%s' % result) for item in result['mrs_production_process_parameter_all_list']: if item: - _logger.info('create可选参数:%s' % item) production_process_parameter = self.search( [("code", '=', item['code'])]) process = self.env['sf.production.process'].search( [('code', '=', item['process_id_code'])], limit=1) if not production_process_parameter: - _logger.info('create可选参数:%s' % item) self.create({ "name": item['name'], "code": item['code'], @@ -985,11 +938,9 @@ class MachineToolCategory(models.Model): # 定时同步机床类型 def sync_machine_tool_category_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1014,11 +965,9 @@ class MachineToolCategory(models.Model): # 同步所有机床类型 def sync_all_machine_tool_category(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1051,11 +1000,9 @@ class sfSyncCutting_tool_Material(models.Model): # 定时同步每日刀具物料 def sync_cutting_tool_material_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1083,11 +1030,9 @@ class sfSyncCutting_tool_Material(models.Model): # 同步所有刀具物料 def sync_all_cutting_tool_material(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1122,11 +1067,9 @@ class SyncFunctionalCuttingToolModel(models.Model): # 定时同步每日功能刀具类型列表 def sync_functional_cutting_tool_model_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1154,12 +1097,9 @@ class SyncFunctionalCuttingToolModel(models.Model): # 同步所有功能刀具类型列表 def sync_all_functional_cutting_tool_model(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1194,11 +1134,9 @@ class SyncFixtureMaterial(models.Model): # 定时同步夹具物料列表 def sync_fixture_material_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1228,12 +1166,9 @@ class SyncFixtureMaterial(models.Model): # 定时同步所有夹具物料列表 def sync_all_fixture_material(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1270,11 +1205,9 @@ class SyncMulti_Mounting_Type(models.Model): # 定时同步联装类型列表 def sync_multi_mounting_type_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1301,11 +1234,9 @@ class SyncMulti_Mounting_Type(models.Model): # 定时同步所有联装类型列表 def sync_all_multi_mounting_type(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1340,11 +1271,9 @@ class SyncFixtureModel(models.Model): # 定时同步夹具型号列表 def sync_fixture_model_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1419,11 +1348,9 @@ class SyncFixtureModel(models.Model): # 定时同步所有夹具型号列表 def sync_all_fixture_model(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1506,11 +1433,9 @@ class SyncFunctionalFixtureType(models.Model): # 定时同步功能夹具类型列表 def sync_functional_fixture_type_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1538,11 +1463,9 @@ class SyncFunctionalFixtureType(models.Model): # 定时同步所有功能夹具类型列表 def sync_all_functional_fixture_type(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) @@ -1577,16 +1500,13 @@ class SfToolType(models.Model): # 定时同步每日刀具类型 def sync_tool_type_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: - _logger.info('result:%s' % result) for item in result['mrs_cutting_tool_type_yesterday_list']: if item: cutting_tool_type = self.search([("code", '=', item['code'])]) @@ -1612,16 +1532,13 @@ class SfToolType(models.Model): # 同步所有刀具类型列表 def sync_all_tool_type(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: - _logger.info('result:%s' % result) for item in result['mrs_cutting_tool_type_all_list']: if item: cutting_tool_type = self.search([("code", '=', item['code'])]) @@ -1655,16 +1572,13 @@ class SfMaintenanceEquipmentImage(models.Model): # 定时同步每日能力特征库 def sync_maintenance_equipment_image_yesterday(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: - _logger.info('result:%s' % result) for item in result['ability_feature_library_yesterday_list']: if item: ability_feature_library = self.search([("name", '=', item['name'])]) @@ -1686,16 +1600,13 @@ class SfMaintenanceEquipmentImage(models.Model): # 同步所有能力特征库 def sync_all_maintenance_equipment_image(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: - _logger.info('result:%s' % result) for item in result['ability_feature_library_all_list']: if item: ability_feature_library = self.search([("name", '=', item['name'])]) @@ -1715,6 +1626,7 @@ class SfMaintenanceEquipmentImage(models.Model): else: raise ValidationError("认证未通过") + class MaterialApply(models.Model): _inherit = 'material.apply' _description = '材料应用' @@ -1722,53 +1634,48 @@ class MaterialApply(models.Model): # 定时同步材料应用 def sync_material_apply(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: for item in result['material_apply_yesterday_list']: - brand = self.env['material.apply'].search( - [("name", '=', item['name'])]) - if brand: - brand.name = item['name'], - brand.active = item['active'] + material_apply = self.search([("name", '=', item['name'])]) + if material_apply: + material_apply.name = item['name'] + material_apply.active = item['active'] else: - self.env['material.apply'].create({ + self.create({ "name": item['name'], "active": item['active'], - }) else: - raise ValidationError("认证未通过") + raise ValidationError("材料应用认证未通过") # 同步所有材料应用 def sync_all_material_apply(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: for item in result['material_apply_all_list']: - brand = self.env['material.apply'].search( - [("name", '=', item['name'])]) - if not brand: - self.env['material.apply'].create({ + material_apply = self.search([("name", '=', item['name'])]) + if not material_apply: + self.create({ "name": item['name'], "active": item['active'], }) + else: + material_apply.name = item['name'] + material_apply.active = item['active'] else: - raise ValidationError("认证未通过") + raise ValidationError("材料应用认证未通过") + class ModelInternationalStandards(models.Model): _inherit = 'sf.international.standards' @@ -1777,50 +1684,382 @@ class ModelInternationalStandards(models.Model): # 定时同步制造标准 def sync_mrs_international_standards(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: for item in result['mrs_international_standards_yesterday_list']: - brand = self.env['sf.international.standards'].search( - [("name", '=', item['name'])]) - if brand: - brand.name = item['name'], - brand.active = item['active'] + international_standards = self.search([("name", '=', item['name'])]) + if international_standards: + international_standards.name = item['name'] + international_standards.active = item['active'] else: - self.env['sf.international.standards'].create({ + self.create({ "name": item['name'], + "code": item['code'], "active": item['active'], - }) else: - raise ValidationError("认证未通过") + raise ValidationError("制造标准认证未通过") # 同步所有制造标准 def sync_all_mrs_international_standards(self): - sf_sync_config = self.env['res.config.settings'].get_values() - token = sf_sync_config['token'] - sf_secret_key = sf_sync_config['sf_secret_key'] - headers = Common.get_headers(self, token, sf_secret_key) - - strUrl = sf_sync_config['sf_url'] + self.url + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url r = requests.post(strUrl, json={}, data=None, headers=headers) r = r.json() result = json.loads(r['result']) if result['status'] == 1: for item in result['mrs_international_standards_all_list']: - brand = self.env['sf.international.standards'].search( - [("name", '=', item['name'])]) - if not brand: - self.env['sf.international.standards'].create({ + international_standards = self.search([("name", '=', item['name'])]) + if not international_standards: + self.create({ "name": item['name'], + "code": item['code'], "active": item['active'], }) + else: + international_standards.name = item['name'] + international_standards.active = item['active'] else: - raise ValidationError("能力特征库认证未通过") + raise ValidationError("制造标准认证未通过") + + +class Cutting_tool_standard_library(models.Model): + _inherit = 'sf.cutting_tool.standard.library' + _description = '刀具标准库' + url = '/api/cutting_tool_standard_library/list' + + # 定时同步刀具标准库 + def sync_cutting_tool_standard_library_yesterday(self): + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url + r = requests.post(strUrl, json={}, data=None, headers=headers) + r = r.json() + result = json.loads(r['result']) + if result['status'] == 1: + for item in result['cutting_tool_standard_library_yesterday_list']: + cutting_tool_standard_library = self.search( + [("code", '=', item['code'].replace("JKM", result['factory_short_name']))]) + cutting_tool_type = self.env['sf.cutting.tool.type'].search( + [("code", '=', item['cutting_tool_type_code'])]) + cutting_tool_material = self.env['sf.cutting.tool.material'].search( + [("code", '=', item['cutting_tool_material_code'])]) + materials_model = self.env['sf.materials.model'].search( + [("materials_no", '=', item['material_model_code'])]) + brand = self.env['sf.machine.brand'].search([("code", '=', item['brand_code'])]) + integral_tool_basic_param_list = [] + for integral_tool_item in item['integral_tool_basic_parameter']: + integral_tool_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_integral_tool_basic_param( + integral_tool_item)) + blade_basic_param_list = [] + for blade_item in item['blade_basic_parameter']: + blade_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_blade_basic_param(blade_item)) + cutter_arbor_basic_param_list = [] + for cutter_arbor_item in item['cutter_arbor_basic_parameter']: + cutter_arbor_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_cutter_arbor_basic_param( + cutter_arbor_item)) + cutter_head_basic_param_list = [] + for cutter_head_item in item['cutter_head_basic_parameter']: + cutter_head_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_cutter_head_basic_param(cutter_head_item)) + knife_handle_basic_param_list = [] + for knife_handle_item in item['knife_handle_basic_parameter']: + knife_handle_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_knife_handle_basic_param( + knife_handle_item)) + chuck_basic_param_list = [] + for chuck_item in item['chuck_basic_parameter']: + chuck_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_chuck_basic_param(chuck_item)) + cutting_speed_list = [] + for cutting_speed_item in item['cutting_speed']: + cutting_speed_list.append( + self.env['sf.cutting.speed']._json_cutting_speed(cutting_speed_item)) + feed_per_tooth_list = [] + for feed_per_tooth_item in item['feed_per_tooth']: + feed_per_tooth_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_item)) + feed_per_tooth_2_list = [] + for feed_per_tooth_2_item in item['feed_per_tooth_2']: + feed_per_tooth_2_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_2_item)) + feed_per_tooth_3_list = [] + for feed_per_tooth_3_item in item['feed_per_tooth_3']: + feed_per_tooth_3_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_3_item)) + feed_per_tooth_4_list = [] + for feed_per_tooth_4_item in item['feed_per_tooth_4']: + feed_per_tooth_4_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_4_item)) + if not cutting_tool_standard_library: + self.create({ + "code": item['code'].replace("JKM", result['factory_short_name']), + "name": item['name'], + "cutting_tool_material_id": cutting_tool_material.id, + "cutting_tool_type_id": cutting_tool_type.id, + "brand_id": brand.id, + "material_model_id": materials_model.id, + "tool_hardness": item['tool_hardness'], + "coating_material": item['coating_material'], + "blade_type": item['blade_type'], + "integral_coarse_medium_fine": item['integral_coarse_medium_fine'], + "integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'], + "integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'], + "cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_bar_codes'], + result['factory_short_name']), + "cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_pad_codes'], + result['factory_short_name']), + "fit_blade_shape_id": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[ + 'maintenance.equipment.image']._get_ids(item['fit_blade_shape']), + "suitable_machining_method_ids": [(6, 0, [])] if not item.get( + 'suitable_machining_methods') else self.env['maintenance.equipment.image']._get_ids( + item['suitable_machining_methods']), + "blade_tip_characteristics_id": [(6, 0, [])] if not item.get('blade_tip_characteristics') else + self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']), + "handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[ + 'maintenance.equipment.image']._get_ids(item['handle_type']), + "cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[ + 'maintenance.equipment.image']._get_ids(item['cutting_direction']), + "suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[ + 'maintenance.equipment.image']._get_ids(item['suitable_coolant']), + "compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[ + 'maintenance.equipment.image']._get_ids(item['compaction_way']), + "integral_tool_basic_parameters_ids": integral_tool_basic_param_list, + "blade_basic_parameters_ids": blade_basic_param_list, + "cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list, + "cutter_head_basic_parameters_ids": cutter_head_basic_param_list, + "knife_handle_basic_parameters_ids": knife_handle_basic_param_list, + "chuck_basic_parameters_ids": chuck_basic_param_list, + "cutting_speed_ids": cutting_speed_list, + "feed_per_tooth_ids": feed_per_tooth_list, + "feed_per_tooth_ids_2": feed_per_tooth_2_list, + "feed_per_tooth_ids_3": feed_per_tooth_3_list, + "feed_per_tooth_ids_4": feed_per_tooth_4_list, + "is_cloud": True, + "active": item['active'], + }) + else: + cutting_tool_standard_library.write( + {"name": item['name'], + "cutting_tool_material_id": cutting_tool_material.id, + "cutting_tool_type_id": cutting_tool_type.id, + "brand_id": brand.id, + "material_model_id": materials_model.id, + "tool_hardness": item['tool_hardness'], + "coating_material": item['coating_material'], + "blade_type": item['blade_type'], + "integral_coarse_medium_fine": item['integral_coarse_medium_fine'], + "integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'], + "integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'], + "cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_bar_codes'], + result['factory_short_name']), + "cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_pad_codes'], + result['factory_short_name']), + "fit_blade_shape_id": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[ + 'maintenance.equipment.image']._get_ids(item['fit_blade_shape']), + "suitable_machining_method_ids": [(6, 0, [])] if not item.get( + 'suitable_machining_methods') else self.env['maintenance.equipment.image']._get_ids( + item['suitable_machining_methods']), + "blade_tip_characteristics_id": [(6, 0, [])] if not item.get('blade_tip_characteristics') else + self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']), + "handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[ + 'maintenance.equipment.image']._get_ids(item['handle_type']), + "cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[ + 'maintenance.equipment.image']._get_ids(item['cutting_direction']), + "suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[ + 'maintenance.equipment.image']._get_ids(item['suitable_coolant']), + "compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[ + 'maintenance.equipment.image']._get_ids(item['compaction_way']), + "integral_tool_basic_parameters_ids": integral_tool_basic_param_list, + "blade_basic_parameters_ids": blade_basic_param_list, + "cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list, + "cutter_head_basic_parameters_ids": cutter_head_basic_param_list, + "knife_handle_basic_parameters_ids": knife_handle_basic_param_list, + "chuck_basic_parameters_ids": chuck_basic_param_list, + "cutting_speed_ids": cutting_speed_list, + "feed_per_tooth_ids": feed_per_tooth_list, + "feed_per_tooth_ids_2": feed_per_tooth_2_list, + "feed_per_tooth_ids_3": feed_per_tooth_3_list, + "feed_per_tooth_ids_4": feed_per_tooth_4_list, + "active": item['active'], + }) + else: + raise ValidationError("刀具标准库认证未通过") + + # 同步所有刀具标准库 + def sync_all_cutting_tool_standard_library(self): + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url + r = requests.post(strUrl, json={}, data=None, headers=headers) + r = r.json() + result = json.loads(r['result']) + if result['status'] == 1: + for item in result['cutting_tool_standard_library_all_list']: + cutting_tool_standard_library = self.search( + [("code", '=', item['code'].replace("JKM", result['factory_short_name']))]) + cutting_tool_type = self.env['sf.cutting.tool.type'].search( + [("code", '=', item['cutting_tool_type_code'])]) + cutting_tool_material = self.env['sf.cutting.tool.material'].search( + [("code", '=', item['cutting_tool_material_code'])]) + materials_model = self.env['sf.materials.model'].search( + [("materials_no", '=', item['material_model_code'])]) + brand = self.env['sf.machine.brand'].search([("code", '=', item['brand_code'])]) + integral_tool_basic_param_list = [] + for integral_tool_item in item['integral_tool_basic_parameter']: + integral_tool_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_integral_tool_basic_param( + integral_tool_item)) + blade_basic_param_list = [] + for blade_item in item['blade_basic_parameter']: + blade_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_blade_basic_param(blade_item)) + cutter_arbor_basic_param_list = [] + for cutter_arbor_item in item['cutter_arbor_basic_parameter']: + cutter_arbor_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_cutter_arbor_basic_param( + cutter_arbor_item)) + cutter_head_basic_param_list = [] + for cutter_head_item in item['cutter_head_basic_parameter']: + cutter_head_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_cutter_head_basic_param(cutter_head_item)) + knife_handle_basic_param_list = [] + for knife_handle_item in item['knife_handle_basic_parameter']: + knife_handle_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_knife_handle_basic_param( + knife_handle_item)) + chuck_basic_param_list = [] + for chuck_item in item['chuck_basic_parameter']: + chuck_basic_param_list.append( + self.env['sf.tool.materials.basic.parameters']._json_chuck_basic_param(chuck_item)) + cutting_speed_list = [] + for cutting_speed_item in item['cutting_speed']: + cutting_speed_list.append( + self.env['sf.cutting.speed']._json_cutting_speed(cutting_speed_item)) + feed_per_tooth_list = [] + for feed_per_tooth_item in item['feed_per_tooth']: + feed_per_tooth_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_item)) + feed_per_tooth_2_list = [] + for feed_per_tooth_2_item in item['feed_per_tooth_2']: + feed_per_tooth_2_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth_2(feed_per_tooth_2_item)) + feed_per_tooth_3_list = [] + for feed_per_tooth_3_item in item['feed_per_tooth_3']: + feed_per_tooth_3_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth_3(feed_per_tooth_3_item)) + feed_per_tooth_4_list = [] + for feed_per_tooth_4_item in item['feed_per_tooth_4']: + feed_per_tooth_4_list.append( + self.env['sf.feed.per.tooth']._json_feed_per_tooth_4(feed_per_tooth_4_item)) + if not cutting_tool_standard_library: + self.create({ + "code": item['code'].replace("JKM", result['factory_short_name']), + "name": item['name'], + "cutting_tool_material_id": cutting_tool_material.id, + "cutting_tool_type_id": cutting_tool_type.id, + "brand_id": brand.id, + "material_model_id": materials_model.id, + "tool_hardness": item['tool_hardness'], + "coating_material": item['coating_material'], + "blade_type": item['blade_type'], + "integral_coarse_medium_fine": item['integral_coarse_medium_fine'], + "integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'], + "integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'], + "cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_bar_codes'], + result['factory_short_name']), + "cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_pad_codes'], + result['factory_short_name']), + "fit_blade_shape_id": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[ + 'maintenance.equipment.image']._get_ids(item['fit_blade_shape']), + "suitable_machining_method_ids": [(6, 0, [])] if not item.get( + 'suitable_machining_method') else self.env['maintenance.equipment.image']._get_ids( + item['suitable_machining_method']), + "blade_tip_characteristics_id": [(6, 0, [])] if not item.get('blade_tip_characteristics') else + self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']), + "handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[ + 'maintenance.equipment.image']._get_ids(item['handle_type']), + "cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[ + 'maintenance.equipment.image']._get_ids(item['cutting_direction']), + "suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[ + 'maintenance.equipment.image']._get_ids(item['suitable_coolant']), + "compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[ + 'maintenance.equipment.image']._get_ids(item['compaction_way']), + "integral_tool_basic_parameters_ids": integral_tool_basic_param_list, + "blade_basic_parameters_ids": blade_basic_param_list, + "cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list, + "cutter_head_basic_parameters_ids": cutter_head_basic_param_list, + "knife_handle_basic_parameters_ids": knife_handle_basic_param_list, + "chuck_basic_parameters_ids": chuck_basic_param_list, + "cutting_speed_ids": cutting_speed_list, + "feed_per_tooth_ids": feed_per_tooth_list, + "feed_per_tooth_ids_2": feed_per_tooth_2_list, + "feed_per_tooth_ids_3": feed_per_tooth_3_list, + "feed_per_tooth_ids_4": feed_per_tooth_4_list, + "is_cloud": True, + "active": item['active'], + }) + else: + cutting_tool_standard_library.write( + {"name": item['name'], + "cutting_tool_material_id": cutting_tool_material.id, + "cutting_tool_type_id": cutting_tool_type.id, + "brand_id": brand.id, + "material_model_id": materials_model.id, + "tool_hardness": item['tool_hardness'], + "coating_material": item['coating_material'], + "blade_type": item['blade_type'], + "integral_coarse_medium_fine": item['integral_coarse_medium_fine'], + "integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'], + "integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'], + "cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_bar_codes'], + result['factory_short_name']), + "cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[ + 'sf.cutting_tool.standard.library']._get_ids(item['cutter_pad_codes'], + result['factory_short_name']), + "fit_blade_shape_id": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[ + 'maintenance.equipment.image']._get_ids(item['fit_blade_shape']), + "suitable_machining_method_ids": [(6, 0, [])] if not item.get( + 'suitable_machining_methods') else self.env['maintenance.equipment.image']._get_ids( + item['suitable_machining_methods']), + "blade_tip_characteristics_id": [(6, 0, [])] if not item.get('blade_tip_characteristics') else + self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']), + "handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[ + 'maintenance.equipment.image']._get_ids(item['handle_type']), + "cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[ + 'maintenance.equipment.image']._get_ids(item['cutting_direction']), + "suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[ + 'maintenance.equipment.image']._get_ids(item['suitable_coolant']), + "compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[ + 'maintenance.equipment.image']._get_ids(item['compaction_way']), + "integral_tool_basic_parameters_ids": integral_tool_basic_param_list, + "blade_basic_parameters_ids": blade_basic_param_list, + "cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list, + "cutter_head_basic_parameters_ids": cutter_head_basic_param_list, + "knife_handle_basic_parameters_ids": knife_handle_basic_param_list, + "chuck_basic_parameters_ids": chuck_basic_param_list, + "cutting_speed_ids": cutting_speed_list, + "feed_per_tooth_ids": feed_per_tooth_list, + "feed_per_tooth_ids_2": feed_per_tooth_2_list, + "feed_per_tooth_ids_3": feed_per_tooth_3_list, + "feed_per_tooth_ids_4": feed_per_tooth_4_list, + "active": item['active'], + }) + else: + raise ValidationError("刀具标准库认证未通过") diff --git a/sf_mrs_connect/security/ir.model.access.csv b/sf_mrs_connect/security/ir.model.access.csv new file mode 100644 index 00000000..0ed43a62 --- /dev/null +++ b/sf_mrs_connect/security/ir.model.access.csv @@ -0,0 +1,7 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sf_static_resource_datasync,sf_static_resource_datasync,model_sf_static_resource_datasync,base.group_user,1,1,1,1 + + + + + diff --git a/sf_sale/models/auto_quatotion_common.py b/sf_sale/models/auto_quatotion_common.py index 09ea3f0f..2d34a76e 100644 --- a/sf_sale/models/auto_quatotion_common.py +++ b/sf_sale/models/auto_quatotion_common.py @@ -2,7 +2,7 @@ import logging from odoo.modules import get_resource_path from odoo import fields, models, api -from quatotion import readSql, feature_recognize, auto_quatotion +#from quatotion import readSql, feature_recognize, auto_quatotion __author__ = 'jinling.yang' _logger = logging.getLogger(__name__) @@ -24,14 +24,14 @@ class AutoQuatotion(models.Model): def get_process_time_db_path(self): return get_resource_path('sf_sale', 'models', 'process_time.db') - def get_auto_quatotion(self, stp_url, feature_full_path, process_time_db_path, model_code): - ''' - 通过打包好的.so库, - 以调用autoQuatotion库中Quatotion类, - 初始化后调用类的analyseShape方法对模型文件进行价格预测 - ''' - # 初始化自动报价类(输入特征数据库和加工时间数据库) - reader = auto_quatotion.Quatotion(feature_full_path, process_time_db_path) - # 获取价格、加工时间、尺寸、XYZ、翻面次数 - feature_info = reader.analyseShape(stp_url, InfoJson={}) - return feature_info + # def get_auto_quatotion(self, stp_url, feature_full_path, process_time_db_path, model_code): + # ''' + # 通过打包好的.so库, + # 以调用autoQuatotion库中Quatotion类, + # 初始化后调用类的analyseShape方法对模型文件进行价格预测 + # ''' + # # 初始化自动报价类(输入特征数据库和加工时间数据库) + # reader = auto_quatotion.Quatotion(feature_full_path, process_time_db_path) + # # 获取价格、加工时间、尺寸、XYZ、翻面次数 + # feature_info = reader.analyseShape(stp_url, InfoJson={}) + # return feature_info diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index caadb6c2..238bb5d8 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -1,7 +1,7 @@ from odoo import models, fields, api 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 from odoo.exceptions import ValidationError, UserError from odoo.addons.sf_base.commons.common import Common from datetime import datetime diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 11811657..4b9edfe6 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -14,9 +14,9 @@ class FunctionalCuttingToolEntity(models.Model): # code = fields.Char('序列号') barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - name = fields.Char('名称', size=20) + name = fields.Char(related='barcode_id.name') functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) - mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号') + mrs_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号') mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True) @@ -67,10 +67,10 @@ class FunctionalCuttingToolEntity(models.Model): domain=[('type', '=', '加工能力')], related='cutting_tool_integral_model_id.suitable_machining_method_ids') - blade_tip_characteristics_ids = fields.Many2many('maintenance.equipment.image', + blade_tip_characteristics_id = fields.Many2many('maintenance.equipment.image', 'rel_blade_tip_product_template_tool_entity', '刀尖特征', domain=[('type', '=', '刀尖特征')], - related='cutting_tool_integral_model_id.blade_tip_characteristics_ids') + related='cutting_tool_integral_model_id.blade_tip_characteristics_id') handle_type_ids = fields.Many2many('maintenance.equipment.image', 'rel_handle_product_template_tool_entity', '柄部类型', @@ -90,7 +90,7 @@ class FunctionalCuttingToolEntity(models.Model): def _get_functional_tool_model_ids(self, functional_tool_model_code): functional_tool_model_ids = [] for item in functional_tool_model_code: - functional_tool_model = self.env['sf.cutting.tool.model'].search([('code', '=', item)]) + functional_tool_model = self.env['sf.cutting_tool.standard.library'].search([('code', '=', item)]) functional_tool_model_ids.append(functional_tool_model.id) return [(6, 0, functional_tool_model_ids)] @@ -623,7 +623,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): """ record = self.env['sf.functional.tool.assembly'].create({ 'barcode_id': self.barcode_id.id, - 'name': self.functional_tool_name_id.id, + 'functional_tool_name_id': self.functional_tool_name_id.id, 'functional_tool_type_id': self.functional_tool_type_id.id, 'functional_tool_diameter': self.diameter, 'functional_tool_length': self.tool_loading_length, @@ -664,7 +664,6 @@ class CAMWorkOrderProgramKnifePlan(models.Model): }) - class FunctionalToolAssembly(models.Model): _name = 'sf.functional.tool.assembly' _description = '功能刀具组装单' @@ -673,7 +672,7 @@ class FunctionalToolAssembly(models.Model): assembly_order_code = fields.Char(string='编码', readonly=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) - name = fields.Char( string='功能刀具名称', readonly=True) + name = fields.Char(string='名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, group_expand='_read_group_functional_tool_type_ids') diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py index 91782faf..32b4d6a8 100644 --- a/sf_tool_management/models/tool_material_search.py +++ b/sf_tool_management/models/tool_material_search.py @@ -55,7 +55,7 @@ class SfToolMaterialSearch(models.Model): blade_radius = fields.Float('刀片刀尖半径(mm)') blade_nut = fields.Float('刀片配对螺母(mm)') mrs_cutting_tool_model_blade_cutter_bar_ids = fields.Many2many( - 'sf.cutting.tool.model', + 'sf.cutting_tool.standard.library', relation='sf_tool_material_search_blade_cutter_bar_rel', column1='model_id_1', column2='model_id_2', @@ -64,7 +64,7 @@ class SfToolMaterialSearch(models.Model): default=lambda self: [], # 使用空列表作为默认值 ) mrs_cutting_tool_model_blade_cutter_pad_ids = fields.Many2many( - 'sf.cutting.tool.model', + 'sf.cutting_tool.standard.library', relation='sf_tool_material_search_blade_cutter_pad_rel', column1='model_id_1', column2='model_id_2', @@ -97,7 +97,7 @@ class SfToolMaterialSearch(models.Model): suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image', 'rel_machining_product_template_material_search', '适合加工方式', domain=[('type', '=', '加工能力')]) - blade_tip_characteristics_ids = fields.Many2many('maintenance.equipment.image', + blade_tip_characteristics_id = fields.Many2many('maintenance.equipment.image', 'rel_blade_tip_product_template_material_search', '刀尖特征', domain=[('type', '=', '刀尖特征')]) handle_type_ids = fields.Many2many('maintenance.equipment.image', @@ -204,7 +204,7 @@ class SfToolMaterialSearch(models.Model): bar_blade_number = fields.Integer('刀杆刃数') bar_d_diameter = fields.Float('刀杆D刃径(mm)') mrs_cutting_tool_model_bar_blade_ids = fields.Many2many( - 'sf.cutting.tool.model', + 'sf.cutting_tool.standard.library', relation='sf_tool_material_search_bar_blade_rel', column1='model_id_1', column2='model_id_2', @@ -226,7 +226,7 @@ class SfToolMaterialSearch(models.Model): pad_blade_number = fields.Integer('刀盘刃数') pad_d_diameter = fields.Float('刀盘D刃径(mm)') mrs_cutting_tool_model_pad_blade_ids = fields.Many2many( - 'sf.cutting.tool.model', + 'sf.cutting_tool.standard.library', relation='sf_tool_material_search_pad_blade_rel', column1='model_id_1', column2='model_id_2', @@ -256,7 +256,7 @@ class SfToolMaterialSearch(models.Model): handle_body_accuracy = fields.Float('刀柄本体精度(mm)') handle_nut = fields.Float('刀柄配对螺母(mm)') mrs_cutting_tool_model_handle_chuck_model_ids = fields.Many2many( - 'sf.cutting.tool.model', + 'sf.cutting_tool.standard.library', relation='sf_tool_material_search_handle_chuck_rel', column1='model_id_1', column2='model_id_2', @@ -280,7 +280,7 @@ class SfToolMaterialSearch(models.Model): chuck_height = fields.Float('夹头高度(mm)') chuck_nut = fields.Float('夹头配对螺母(mm)') mrs_cutting_tool_model_chuck_handle_model_ids = fields.Many2many( - 'sf.cutting.tool.model', + 'sf.cutting_tool.standard.library', relation='sf_tool_material_search_chuck_handle_rel', column1='model_id_1', column2='model_id_2', diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 4b948b7a..c1495df7 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -99,8 +99,8 @@ - + - + @@ -231,7 +231,7 @@ - + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 2e2bc17f..0c554ca9 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -273,7 +273,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel): stock_lot = self.create_assemble_warehouse_receipt() # 创建刀具组装入库单 self.create_stocking_picking(stock_lot) - print('已运行1') desc_1 = { 'barcode_id': stock_lot.id, 'integral_code_id': self.integral_code_id.id, @@ -293,13 +292,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'tool_loading_person': self.env.user.name, 'tool_loading_time': fields.Datetime.now() } - print('已运行2') functional_tool_assembly = self.env['sf.functional.tool.assembly'].search([ ('machine_tool_name_id', '=', self.machine_tool_name_id.id), ('cutter_spacing_code', '=', self.cutter_spacing_code), ('assemble_status', '=', '0'), ]) - print('已运行3') # 封装功能刀具数据 desc_2 = { 'barcode_id': stock_lot.id, @@ -323,10 +320,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'applicable_range': None, 'image': None, } - print('已运行4') # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) - print('已运行5') self.env['sf.functional.tool.warning'].create({ 'functional_cutting_tool_id': record_1.id, 'functional_tool_assembly_id': functional_tool_assembly.id,