From a07563e166c05daac7003cfb055c12f2e23d7925 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 20 Mar 2024 16:34:11 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E5=A4=B9=E5=85=B7?= =?UTF-8?q?=E7=89=A9=E6=96=99=E6=90=9C=E7=B4=A2=E6=A8=A1=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E5=AE=8C=E6=88=90tree=E8=A7=86=E5=9B=BE=E5=92=8Cform=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=EF=BC=9B2=E3=80=81=E6=96=B0=E5=A2=9E=E5=A4=B9?= =?UTF-8?q?=E5=85=B7=E7=89=A9=E6=96=99=E5=BA=8F=E5=88=97=E5=8F=B7=E3=80=81?= =?UTF-8?q?=E5=A4=B9=E5=85=B7=E7=89=A9=E6=96=99=E6=90=9C=E7=B4=A2=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=B3=A8=E5=86=8C=E5=88=B0cloud=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E4=BC=98=E5=8C=96=E5=88=80=E5=85=B7=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=BA=8F=E5=88=97=E5=8F=B7=E6=B3=A8=E5=86=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=8A=E6=B5=81=E7=A8=8B=EF=BC=9B3=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A8=A1=E5=9E=8B=E7=9A=84=E6=97=A0=E5=85=B3=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/__manifest__.py | 1 + sf_tool_management/models/__init__.py | 2 + sf_tool_management/models/fixture_enroll.py | 82 +++++ .../models/fixture_material_search.py | 55 ++++ .../models/functional_tool_enroll.py | 21 +- .../models/maintenance_equipment.py | 44 ++- .../models/tool_material_search.py | 304 ------------------ .../security/ir.model.access.csv | 2 + .../views/fixture_material_search_views.xml | 105 ++++++ .../views/tool_material_search.xml | 1 - 10 files changed, 278 insertions(+), 339 deletions(-) create mode 100644 sf_tool_management/models/fixture_enroll.py create mode 100644 sf_tool_management/models/fixture_material_search.py create mode 100644 sf_tool_management/views/fixture_material_search_views.xml diff --git a/sf_tool_management/__manifest__.py b/sf_tool_management/__manifest__.py index 3eee245a..a7750f69 100644 --- a/sf_tool_management/__manifest__.py +++ b/sf_tool_management/__manifest__.py @@ -20,6 +20,7 @@ 'views/sf_maintenance_equipment.xml', 'views/menu_view.xml', 'views/tool_material_search.xml', + 'views/fixture_material_search_views.xml', ], 'demo': [ ], diff --git a/sf_tool_management/models/__init__.py b/sf_tool_management/models/__init__.py index 05637f26..f73f5e3d 100644 --- a/sf_tool_management/models/__init__.py +++ b/sf_tool_management/models/__init__.py @@ -3,4 +3,6 @@ from . import tool_material_search from . import maintenance_equipment from . import mrp_workorder from . import functional_tool_enroll +from . import fixture_material_search +from . import fixture_enroll diff --git a/sf_tool_management/models/fixture_enroll.py b/sf_tool_management/models/fixture_enroll.py new file mode 100644 index 00000000..24e4e9f5 --- /dev/null +++ b/sf_tool_management/models/fixture_enroll.py @@ -0,0 +1,82 @@ +import json +import base64 +import requests +from odoo import models, api +from odoo.addons.sf_base.commons.common import Common +from odoo.exceptions import UserError + + +class StockLot(models.Model): + _inherit = 'stock.lot' + _description = '夹具物料序列号注册' + + def enroll_fixture_material_stock(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) + str_url = sf_sync_config['sf_url'] + "/api/fixture_material_stock/create" + objs_all = self.env['stock.lot'].search([('id', '=', self.id)]) + fixture_material_stock_list = [] + if objs_all: + for item in objs_all: + val = { + 'name': item.name, + 'tool_material_status': item.tool_material_status, + 'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name, + 'fixture_material_search_id': item.fixture_material_search_id.id, + } + fixture_material_stock_list.append(val) + kw = json.dumps(fixture_material_stock_list, ensure_ascii=False) + r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers) + ret = r.json() + if ret.get('code') == 200: + return '夹具物料序列号注册成功' + else: + raise UserError("没有注册夹具物料序列号信息") + + +class FixtureMaterialSearch(models.Model): + _inherit = 'sf.fixture.material.search' + _description = '夹具物料搜索注册' + + crea_url = "/api/fixture_material/create" + + def enroll_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) + str_url = sf_sync_config['sf_url'] + self.crea_url + objs_all = self.search([('id', '=', self.id)]) + fixture_material_list = [] + if objs_all: + for obj in objs_all: + val = { + 'name': obj.name, + 'id': obj.id, + 'fixture_material_code': obj.fixture_material_id.code, + 'fixture_model_code': obj.fixture_model_id.code, + 'specification_name': obj.specification_fixture_id.name, + 'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'), + 'number': obj.number, + 'usable_num': obj.usable_num, + 'have_been_used_num': obj.have_been_used_num, + 'scrap_num': obj.scrap_num + } + fixture_material_list.append(val) + kw = json.dumps(fixture_material_list, ensure_ascii=False) + r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers) + ret = r.json() + if ret.get('code') == 200: + return '夹具物料注册成功' + else: + raise UserError("没有注册夹具物料信息") + + @api.model_create_multi + def create(self, vals_list): + records = super(FixtureMaterialSearch, self).create(vals_list) + for record in records: + if record: + record.enroll_fixture_material() + return records diff --git a/sf_tool_management/models/fixture_material_search.py b/sf_tool_management/models/fixture_material_search.py new file mode 100644 index 00000000..ea1212a9 --- /dev/null +++ b/sf_tool_management/models/fixture_material_search.py @@ -0,0 +1,55 @@ +from odoo import models, fields, api, SUPERUSER_ID + + +class FixtureMaterialSearch(models.Model): + _name = 'sf.fixture.material.search' + _description = '夹具物料搜索' + + product_id = fields.Many2one('product.product', string='夹具物料产品') + + name = fields.Char('名称', related='product_id.name') + code = fields.Char('编码') + fixture_material_id = fields.Many2one('sf.fixture.material', '夹具物料', + related='product_id.fixture_material_id', + store=True, + group_expand='_read_group_fixture_material_id') + fixture_material_name = fields.Char('物料名称', related='product_id.fixture_material_id.name') + fixture_model_id = fields.Many2one('sf.fixture.model', '夹具型号', + related='product_id.fixture_model_id') + specification_fixture_id = fields.Many2one('sf.fixture.materials.basic.parameters', '规格', + related='product_id.specification_fixture_id') + image = fields.Binary('图片', related='product_id.image_1920') + number = fields.Integer('总数量', compute='_compute_number') + usable_num = fields.Integer('可用数量', compute='_compute_number') + have_been_used_num = fields.Integer('在用数量', compute='_compute_number') + scrap_num = fields.Integer('报废数量', compute='_compute_number') + + barcode_ids = fields.One2many('stock.lot', 'fixture_material_search_id', string='序列号', readonly=True) + + @api.depends('barcode_ids') + def _compute_number(self): + for record in self: + usable_num = 0 + have_been_used_num = 0 + scrap_num = 0 + if record.barcode_ids: + record.number = len(record.barcode_ids) + for barcode_id in record.barcode_ids: + if barcode_id.quant_ids: + if barcode_id.quant_ids[-1].location_id.name not in '夹具房': + have_been_used_num = have_been_used_num + 1 + else: + usable_num = usable_num + 1 + record.usable_num = usable_num + record.have_been_used_num = have_been_used_num + record.scrap_num = scrap_num + else: + record.number = 0 + record.usable_num = 0 + record.have_been_used_num = 0 + record.scrap_num = 0 + + @api.model + def _read_group_fixture_material_id(self, categories, domain, order): + fixture_material_id = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) + return categories.browse(fixture_material_id) diff --git a/sf_tool_management/models/functional_tool_enroll.py b/sf_tool_management/models/functional_tool_enroll.py index 6c35f2ef..c1687cde 100644 --- a/sf_tool_management/models/functional_tool_enroll.py +++ b/sf_tool_management/models/functional_tool_enroll.py @@ -34,14 +34,12 @@ class StockLot(models.Model): _inherit = 'stock.lot' _description = '刀具物料序列号注册' - crea_url = "/api/tool_material_stock/create" - def enroll_tool_material_stock(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) - str_url = sf_sync_config['sf_url'] + self.crea_url + str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create" objs_all = self.env['stock.lot'].search([('id', '=', self.id)]) tool_material_stock_list = [] if objs_all: @@ -61,15 +59,6 @@ class StockLot(models.Model): else: raise UserError("没有注册刀具物料序列号信息") - @api.model_create_multi - def create(self, vals_list): - records = super(StockLot, self).create(vals_list) - for record in records: - if record.product_id.categ_id.name == '刀具': - record.tool_material_status = '未入库' - record.enroll_tool_material_stock() - return records - class ToolMaterial(models.Model): _inherit = 'sf.tool.material.search' @@ -87,10 +76,6 @@ class ToolMaterial(models.Model): tool_material_list = [] if objs_all: for item in objs_all: - barcode_names = [] - for barcode_id in item.barcode_ids: - if barcode_id.name: - barcode_names.append(barcode_id.name) val = { 'name': item.name, 'id': item.id, @@ -101,9 +86,7 @@ class ToolMaterial(models.Model): 'number': item.number, 'usable_num': item.usable_num, 'have_been_used_num': item.have_been_used_num, - 'scrap_num': item.scrap_num, - 'barcode_names': str(barcode_names), - 'active': item.active + 'scrap_num': item.scrap_num } tool_material_list.append(val) kw = json.dumps(tool_material_list, ensure_ascii=False) diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py index 5f2465bf..d39dc685 100644 --- a/sf_tool_management/models/maintenance_equipment.py +++ b/sf_tool_management/models/maintenance_equipment.py @@ -97,6 +97,7 @@ class StockLot(models.Model): _inherit = 'stock.lot' tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索') + fixture_material_search_id = fields.Many2one('sf.fixture.material.search', string='夹具物料搜索') tool_material_status = fields.Selection( [('未入库', '未入库'), ('可用', '可用'), ('在用', '在用'), ('报废', '报废')], string='状态', compute='_compute_tool_material_status', store=True) @@ -105,20 +106,20 @@ class StockLot(models.Model): def _compute_tool_material_status(self): for record in self: if record: - if record.quant_ids: - if record.quant_ids[-1].location_id.name == '刀具房': - record.tool_material_status = '可用' - elif record.quant_ids[-1].location_id.name == '刀具组装位置': - record.tool_material_status = '在用' - else: - record.tool_material_status = '未入库' - - @api.onchange('tool_material_status') - def _onchange_tool_material_status(self): - for obj in self: - if obj: - # 注册刀具物料状态到cloud平台 - obj.enroll_tool_material_stock() + if record.product_id.categ_id.name in ['刀具', '夹具']: + if record.quant_ids: + if record.quant_ids[-1].location_id.name in ['刀具房', '夹具房']: + record.tool_material_status = '可用' + elif record.quant_ids[-1].location_id.name == '刀具组装位置': + record.tool_material_status = '在用' + else: + record.tool_material_status = '未入库' + if record.tool_material_search_id: + # 注册刀具物料状态到cloud平台 + record.enroll_tool_material_stock() + elif record.fixture_material_search_id: + # 注册夹具物料状态到cloud平台 + record.enroll_fixture_material_stock() @api.model def name_search(self, name='', args=None, operator='ilike', limit=100): @@ -149,7 +150,14 @@ class StockLot(models.Model): tool_material_search = self.env['sf.tool.material.search'].sudo().search( [('id', '=', record.product_id.tool_material_id)]) if tool_material_search: - record.tool_material_search_id = tool_material_search + record.tool_material_status = '未入库' + record.tool_material_search_id = tool_material_search.id + elif record.product_id.categ_id.name == '夹具': + fixture_material_search = self.env['sf.fixture.material.search'].sudo().search( + [('id', '=', record.product_id.fixture_material_search_id)]) + if fixture_material_search: + record.tool_material_status = '未入库' + record.fixture_material_search_id = fixture_material_search.id return records @@ -157,6 +165,7 @@ class ProductProduct(models.Model): _inherit = 'product.product' tool_material_id = fields.Char('刀具物料搜索模型ID') + fixture_material_search_id = fields.Char('夹具物料搜索模型ID') @api.model_create_multi def create(self, vals_list): @@ -167,4 +176,9 @@ class ProductProduct(models.Model): 'product_id': record.id }) record.tool_material_id = tool_material.id + elif record.categ_id.name == '夹具': + fixture_material = self.env['sf.fixture.material.search'].sudo().create({ + 'product_id': record.id + }) + record.fixture_material_search_id = fixture_material.id return records diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py index 547bae32..75fc02e0 100644 --- a/sf_tool_management/models/tool_material_search.py +++ b/sf_tool_management/models/tool_material_search.py @@ -2,308 +2,6 @@ from odoo import fields, models, api, SUPERUSER_ID -# from odoo.exceptions import ValidationError - - -# 刀具物料搜索(待删除) -class SfToolMaterialSearch(models.Model): - _name = 'sf.tool.material.search' - _description = '刀具物料搜索' - - sequence = fields.Integer('序号') - code = fields.Char('编码') - name = fields.Char('名称', required=True) - # 关联刀具类型 - mrs_cutting_tool_type_id = fields.Many2one( - 'sf.cutting.tool.type', '刀具类型', - domain="[('cutting_tool_material_id.name', '=', cutting_tool_material_name)]", required=True) - # 关联刀具物料名称 - mrs_cutting_tool_material_name = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料名称', - store=True) - cutting_tool_type = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料类型', store=True) - mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌', required=True, - domain="[('tag_ids.name', 'ilike', '刀具')]") - # 关联刀具型号 - # mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', '刀具型号') - - # 关联刀具物料模型 - mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料', - group_expand='_read_group_mrs_cutting_tool_material_ids', - required=True) - cutting_tool_material_name = fields.Char(string='物料名称', invisible=True) - - @api.onchange('mrs_cutting_tool_material_id') - def _onchange_mrs_cutting_tool_material_id(self): - for record in self: - if record: - record.cutting_tool_material_name = record.mrs_cutting_tool_material_id.name - - @api.model - def _read_group_mrs_cutting_tool_material_ids(self, categories, domain, order): - mrs_cutting_tool_material_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) - return categories.browse(mrs_cutting_tool_material_ids) - - # 刀片特有字段 - blade_code = fields.Char('刀片编码', readonly=True) - blade_length = fields.Float('刀片长度L(mm)') - blade_width = fields.Float('刀片宽度D(mm)') - blade_height = fields.Float('刀片高度T(mm)') - blade_top_angle = fields.Float('刀片顶角(°)') - blade_front_angle = fields.Float('刀片前角(°)') - blade_rear_angle = fields.Float('刀片后角(°)') - blade_main_included_angle = fields.Float('刀片主偏角(°)') - blade_r_angle = fields.Float('刀片R角(°)') - blade_hardness = fields.Integer('刀片加工硬度') - blade_accuracy = fields.Char('刀片精度等级') - blade_coating_material_id = fields.Char('刀片涂层材质') - blade_radius = fields.Float('刀片刀尖半径(mm)') - blade_nut = fields.Float('刀片配对螺母(mm)') - mrs_cutting_tool_model_blade_cutter_bar_ids = fields.Many2many( - 'sf.cutting_tool.standard.library', - relation='sf_tool_material_search_blade_cutter_bar_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀杆')]", - string='适用刀杆型号', - default=lambda self: [], # 使用空列表作为默认值 - ) - mrs_cutting_tool_model_blade_cutter_pad_ids = fields.Many2many( - 'sf.cutting_tool.standard.library', - relation='sf_tool_material_search_blade_cutter_pad_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀盘')]", - string='适用刀盘型号', - default=lambda self: [], # 使用空列表作为默认值 - ) - - # 整体式刀具特有字段 - integral_code = fields.Char('整体式刀具编码', readonly=True) - integral_total_length = fields.Float('整体式刀具总长度(mm)', digits=(6, 1)) - integral_shank_length = fields.Float('整体式刀具柄部长度(mm)', digits=(6, 1)) - integral_blade_length = fields.Float('整体式刀具刃部长度(mm)', digits=(6, 1)) - integral_neck_length = fields.Float('整体式刀具颈部长度(mm)', digits=(6, 1)) - integral_shank_diameter = fields.Float('整体式刀具柄部直径(mm)', digits=(6, 1)) - integral_blade_diameter = fields.Float('整体式刀具刃部直径(mm)', digits=(6, 1)) - integral_neck_diameter = fields.Float('整体式刀具颈部直径(mm)', digits=(6, 1)) - integral_blade_number = fields.Integer('整体式刀具刃数(个)') - integral_blade_tip_diameter = fields.Float('整体式刀具刀尖直径(mm)', digits=(6, 1)) - integral_blade_tip_taper = fields.Float('整体式刀具刀尖锥度(°)', digits=(6, 1)) - integral_blade_helix_angle = fields.Float('整体式刀具刃部螺旋角(°)', digits=(6, 1)) - integral_blade_type = fields.Char('整体式刀具刃部类型') - integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '整体式刀具粗/中/精') - # integral_blade_material = fields.Selection([('碳素钢', '碳素钢'), ('硬质合金', '硬质合金')], '整体式刀具刀具材质') - integral_hardness = fields.Integer('整体式刀具硬度(HRC)') - integral_coating_material = fields.Char('整体式刀具涂层材质') - integral_run_out_accuracy_max = fields.Float('整体式刀具端跳精度max', digits=(6, 1)) - integral_run_out_accuracy_min = fields.Float('整体式刀具端跳精度min', digits=(6, 1)) - - suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image', - 'rel_machining_product_template_material_search', '适合加工方式', - domain=[('type', '=', '加工能力')]) - blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image', '刀尖特征', - domain=[('type', '=', '刀尖特征')]) - handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')]) - cutting_direction_ids = fields.Many2many('maintenance.equipment.image', - 'rel_cutting_product_template_material_search', '走刀方向', - domain=[('type', '=', '走刀方向')]) - suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', - 'rel_coolants_product_template_material_search', '适合冷却方式', - domain=[('type', '=', '冷却方式')]) - - cutting_speed_ids = fields.Many2many('sf.cutting.speed', string='切削速度Vc') - feed_per_tooth_ids = fields.Many2many('sf.feed.per.tooth', 'rel_feed_per_tooth_ids', '每齿走刀量fz') - - # @api.constrains('suitable_machining_method_ids') - # def _check_suitable_machining_method_ids(self): - # for record in self: - # if len(record.suitable_machining_method_ids) == 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("适合加工方式不能为空!") - # - # @api.constrains('blade_tip_characteristics_ids') - # def _check_blade_tip_characteristics_ids(self): - # for record in self: - # if len(record.blade_tip_characteristics_ids) == 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("刀尖特征不能为空!") - # if len(record.blade_tip_characteristics_ids) > 1 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("刀尖特征只能单选!") - # - # @api.constrains('handle_type_ids') - # def _check_handle_type_ids(self): - # for record in self: - # if len(record.handle_type_ids) == 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("柄部类型不能为空!") - # if len(record.handle_type_ids) > 1 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("柄部类型只能单选!") - # - # @api.constrains('cutting_direction_ids') - # def _check_cutting_direction_ids(self): - # for record in self: - # if len(record.cutting_direction_ids) == 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("走刀方向不能为空!") - # - # @api.constrains('suitable_coolant_ids') - # def _check_suitable_coolant_ids(self): - # for record in self: - # if not record.suitable_coolant_ids and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("适合冷却液不能为空!") - # - # @api.constrains('integral_total_length') - # def _check_integral_total_length(self): - # if self.integral_total_length <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("总长度不能为0") - # - # @api.constrains('integral_shank_length') - # def _check_integral_shank_length(self): - # if self.integral_shank_length <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("柄部长度不能为0") - # - # @api.constrains('integral_blade_length') - # def _check_integral_blade_length(self): - # if self.integral_blade_length <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("刃部长度不能为0") - # - # @api.constrains('integral_blade_number') - # def _check_integral_blade_number(self): - # if self.integral_blade_number <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("刃数不能为0") - # - # @api.constrains('integral_shank_diameter') - # def _check_integral_shank_diameter(self): - # if self.integral_shank_diameter <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("柄部直径不能为0") - # - # @api.constrains('integral_blade_diameter') - # def _check_integral_blade_diameter(self): - # if self.integral_blade_diameter <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("刃部直径不能为0") - # - # @api.constrains('integral_run_out_accuracy_min') - # def _check_integral_blade_diameter(self): - # if self.integral_run_out_accuracy_min <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("端跳精度最小(min)不能为0") - # - # @api.constrains('integral_run_out_accuracy_max') - # def _check_integral_run_out_accuracy_max(self): - # if self.integral_run_out_accuracy_max <= 0 and self.cutting_tool_type == '整体式刀具': - # raise ValidationError("端跳精度最大(max)不能为0") - - # integral_front_angle = fields.Float('整体式刀具前角(°)') - # integral_rear_angle = fields.Float('整体式刀具后角(°)') - # integral_main_included_angle = fields.Float('整体式刀具主偏角(°)') - # integral_accuracy = fields.Float('整体式刀具精度等级') - # integral_hardness = fields.Float('整体式刀具加工硬度(HRC)') - # integral_coating_material = fields.Char('整体式刀具涂层材质') - # integral_nut = fields.Float('整体式刀具配对螺母(mm)') - # integral_scope = fields.Char('整体式刀具适用范围') - - # 刀杆特有字段 - bar_code = fields.Char('刀杆编码', readonly=True) - # bar_name = fields.Char('刀杆名称', required=True) - bar_c_diameter = fields.Float('刀杆C柄径(mm)') - bar_total_length = fields.Float('刀杆L总长(mm)') - bar_blade_number = fields.Integer('刀杆刃数') - bar_d_diameter = fields.Float('刀杆D刃径(mm)') - mrs_cutting_tool_model_bar_blade_ids = fields.Many2many( - 'sf.cutting_tool.standard.library', - relation='sf_tool_material_search_bar_blade_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀片')]", - string='刀杆适用刀片型号' - ) - bar_wrench = fields.Float('刀杆配对扳手(mm)') - bar_screw = fields.Float('刀杆配备螺丝(mm)') - bar_radius = fields.Float('刀杆刀尖圆角半径') - bar_accuracy = fields.Char('刀杆精度等级') - bar_hardness = fields.Integer('刀杆硬度(°)') - bar_scope = fields.Char('刀杆适用范围') - - # 刀盘特有字段 - pad_code = fields.Char('刀盘编码', readonly=True) - # pad_name = fields.Char('刀盘名称', required=True) - pad_c_diameter = fields.Float('刀盘C柄径(mm)') - pad_total_length = fields.Float('刀盘L总长(mm)') - pad_blade_number = fields.Integer('刀盘刃数') - pad_d_diameter = fields.Float('刀盘D刃径(mm)') - mrs_cutting_tool_model_pad_blade_ids = fields.Many2many( - 'sf.cutting_tool.standard.library', - relation='sf_tool_material_search_pad_blade_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀片')]", - string='刀盘适用刀片型号' - ) - pad_wrench = fields.Float('刀盘配对扳手(mm)') - pad_screw = fields.Float('刀盘配备螺丝(mm)') - pad_radius = fields.Float('刀盘刀尖圆角半径') - pad_accuracy = fields.Char('刀盘精度等级') - pad_hardness = fields.Integer('刀盘硬度(°)') - pad_scope = fields.Char('刀盘适用范围') - - # 刀柄特有字段 - handle_code = fields.Char('刀柄编码', readonly=True) - # 柄长L(mm)、法兰柄长L1(mm)、法兰直径D1(mm) - handle_length = fields.Float('刀柄柄长L(mm)') - handle_diameter = fields.Float('刀柄直径D(mm)') - handle_flange_length = fields.Float('刀柄法兰柄长L1(mm)') - handle_flange_diameter = fields.Float('刀柄法兰直径D1(mm)') - # 夹持直径min、夹持直径max、径跳精度、最大转速n/min、3D模型图 - handle_clamping_diameter_min = fields.Float('刀柄夹持直径min') - handle_clamping_diameter_max = fields.Float('刀柄夹持直径max') - handle_jump_accuracy = fields.Float('刀柄径跳精度') - handle_max_speed = fields.Float('刀柄最大转速n/min') - handle_weight = fields.Float('刀柄重量(kg)') - handle_body_accuracy = fields.Float('刀柄本体精度(mm)') - handle_nut = fields.Float('刀柄配对螺母(mm)') - mrs_cutting_tool_model_handle_chuck_model_ids = fields.Many2many( - 'sf.cutting_tool.standard.library', - relation='sf_tool_material_search_handle_chuck_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '夹头')]", - string='适用夹头型号' - ) - handle_clamping_range = fields.Float('刀柄夹持范围(mm)') - handle_detection_accuracy = fields.Float('刀柄检测精度') - handle_detection_hardness = fields.Integer('刀柄检测硬度') - handle_standard_speed = fields.Float('刀柄标准转速') - - # 夹头特有字段 - chuck_code = fields.Char('夹头编码', readonly=True) - # chuck_name = fields.Char('夹头名称', required=True) - chuck_accuracy = fields.Float('夹头精度(mm)') - # 夹持直径min、夹持直径max、3D模型图 - chuck_clamping_diameter_min = fields.Float('夹头夹持直径min(mm)') - chuck_clamping_diameter_max = fields.Float('夹头夹持直径max(mm)') - chuck_diameter = fields.Float('夹头外径(mm)') - chuck_inner_diameter = fields.Float('夹头内径(mm)') - chuck_height = fields.Float('夹头高度(mm)') - chuck_nut = fields.Float('夹头配对螺母(mm)') - mrs_cutting_tool_model_chuck_handle_model_ids = fields.Many2many( - 'sf.cutting_tool.standard.library', - relation='sf_tool_material_search_chuck_handle_rel', - column1='model_id_1', - column2='model_id_2', - domain="[('cutting_tool_type', '=', '刀柄')]", - string='适用刀柄型号' - ) - chuck_clamping_range = fields.Float('夹头夹持范围(mm)') - chuck_feature = fields.Char('夹头特性') - image = fields.Binary('夹头图片') - - # 数量、采购入库日期、采购批次、供应商、仓库名称、库区、库位、3D模型 - number = fields.Integer('数量') - mrs_materials_model_id = fields.Many2one('sf.materials.model', '材料型号') - purchase_date = fields.Date('采购入库日期') - purchase_batch = fields.Char('采购批次') - supplier = fields.Char('供应商') - warehouse_name = fields.Char('仓库名称') - warehouse_area = fields.Char('库区') - warehouse_location = fields.Char('库位') - three_d_model = fields.Many2one('ir.attachment', '3D模型') - - class ToolMaterial(models.Model): _name = 'sf.tool.material.search' _description = '刀具物料搜索' @@ -329,8 +27,6 @@ class ToolMaterial(models.Model): barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True) - active = fields.Boolean(string='已归档', default=True) - @api.depends('barcode_ids') def _compute_number(self): for record in self: diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index 6df54c0b..35217493 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -13,6 +13,7 @@ access_sf_tool_transfer_request_information,sf.tool.transfer.request.information access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_sf_tool_user,1,1,1,0 access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_sf_tool_user,1,1,1,0 access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_sf_tool_user,1,1,1,0 +access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_tool_user,1,1,1,0 access_sf_functional_cutting_tool_entity_group_plan_dispatch,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_plan_dispatch,1,0,0,0 @@ -29,3 +30,4 @@ access_sf_tool_transfer_request_information_group_plan_dispatch,sf.tool.transfer access_sf_functional_tool_assembly_group_plan_dispatch,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_plan_dispatch,1,0,0,0 access_sf_functional_tool_assembly_order_group_plan_dispatch,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_plan_dispatch,1,0,0,0 access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0 +access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0 diff --git a/sf_tool_management/views/fixture_material_search_views.xml b/sf_tool_management/views/fixture_material_search_views.xml new file mode 100644 index 00000000..f70eba36 --- /dev/null +++ b/sf_tool_management/views/fixture_material_search_views.xml @@ -0,0 +1,105 @@ + + + + sf.fixture.material.search.tree + sf.fixture.material.search + + + + + + + + + + + + + + + + sf.fixture.material.search.form + sf.fixture.material.search + +
+ + + + +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + sf.fixture.material.search.search + sf.fixture.material.search + + + + + + + + + + + + + + 夹具物料查询 + ir.actions.act_window + sf.fixture.material.search + tree,form + + + +
\ No newline at end of file diff --git a/sf_tool_management/views/tool_material_search.xml b/sf_tool_management/views/tool_material_search.xml index fe08da42..3f3c91a2 100644 --- a/sf_tool_management/views/tool_material_search.xml +++ b/sf_tool_management/views/tool_material_search.xml @@ -82,7 +82,6 @@ -