From 329d7b6464b2c146991a0f4210ae98f5d158c0c5 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 16 Nov 2023 17:36:09 +0800 Subject: [PATCH 01/14] =?UTF-8?q?1=E3=80=81=E6=9C=BA=E5=BA=8A=E6=8D=A2?= =?UTF-8?q?=E5=88=80=E7=94=B3=E8=AF=B7=E7=95=8C=E9=9D=A2=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=9D=A2=E6=9D=BF=E5=92=8C=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=A0=B9=E6=8D=AE=E8=AE=BE=E5=A4=87=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B=E7=AD=89=E4=BA=8E=E6=9C=BA?= =?UTF-8?q?=E5=BA=8A=E7=9A=84=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E9=9A=90=E8=97=8F=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=EF=BC=9B3=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E5=88=97=E8=A1=A8form=E8=A7=86=E5=9B=BE=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=A2=84=E8=AD=A6=E8=B7=B3=E8=BD=AC=E6=8C=89=E9=94=AE?= =?UTF-8?q?=EF=BC=88=E8=B7=B3=E8=BD=AC=E5=8A=9F=E8=83=BD=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90=EF=BC=89=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 7 +- sf_tool_management/views/menu_view.xml | 14 +-- sf_tool_management/views/tool_base_views.xml | 13 +++ sf_tool_management/wizard/wizard.py | 113 +++++++++++-------- 4 files changed, 92 insertions(+), 55 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 1fb775c3..31633de3 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -94,6 +94,9 @@ class FunctionalCuttingToolEntity(models.Model): functional_tool_model_ids.append(functional_tool_model.id) return [(6, 0, functional_tool_model_ids)] + def open_functional_tool_warning(self): + pass + class FunctionalToolWarning(models.Model): _name = 'sf.functional.tool.warning' @@ -438,7 +441,7 @@ class MachineTableToolChangingApply(models.Model): _description = '机床换刀申请' name = fields.Many2one('maintenance.equipment', string='CNC机床', required=True, readonly=False, - group_expand='_read_group_names') + group_expand='_read_group_names', domain=[('category_id.equipment_type', '=', '机床')]) machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True, compute='_compute_machine_table_type_id') machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) @@ -489,7 +492,7 @@ class MachineTableToolChangingApply(models.Model): @api.model def _read_group_names(self, categories, domain, order): - names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) + names = categories._search([('category_id.equipment_type', '=', '机床')], order=order, access_rights_uid=SUPERUSER_ID) return categories.browse(names) @api.onchange('functional_tool_status') diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index 301233c4..5b1ed7e9 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -32,13 +32,13 @@ parent="menu_sf_tool_manage" /> - + + + + + + +
+
+ +

diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 53d7f28a..b5a5b5d0 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -166,14 +166,14 @@ class FunctionalToolAssemblyOrder(models.TransientModel): sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True) # 刀柄型号 - handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', + handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True, domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄')]) cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', readonly=True) handle_name = fields.Char('刀柄名称', readonly=True) sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True) # 夹头型号 - chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', + chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True, domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')]) cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', readonly=True) chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill') @@ -269,58 +269,25 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 功能刀具组装 :return: """ + # 对物料做必填判断 + self.materials_must_be_judged() + # 创建组装入库单 # 创建功能刀具批次/序列号记录 stock_lot = self.create_assemble_warehouse_receipt() # 创建刀具组装入库单 self.create_stocking_picking(stock_lot) - desc_1 = { - 'barcode_id': stock_lot.id, - 'integral_code_id': self.integral_code_id.id, - 'blade_code_id': self.blade_code_id.id, - 'bar_code_id': self.bar_code_id.id, - 'pad_code_id': self.pad_code_id.id, - 'handle_code_id': self.handle_code_id.id, - 'chuck_code_id': self.chuck_code_id.id, - 'coarse_middle_thin': self.coarse_middle_thin, - 'tool_loading_length': self.tool_loading_length, - 'new_former': self.new_former, - 'reference_length': self.reference_length, - 'cut_time': self.cut_time, - 'cut_length': self.cut_length, - 'cut_number': self.cut_number, - 'assemble_status': '1', - 'tool_loading_person': self.env.user.name, - 'tool_loading_time': fields.Datetime.now() - } + # 封装功能刀具数据 + desc_1 = self.get_desc_1(stock_lot) 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'), ]) + + # 创建功能刀具列表记录 # 封装功能刀具数据 - desc_2 = { - 'barcode_id': stock_lot.id, - 'functional_tool_name_id': self.functional_tool_name_id.id, - 'mrs_cutting_tool_type_id': self.functional_tool_type_id.id, - 'cutting_tool_integral_model_id': self.integral_code_id.product_id.id, - 'cutting_tool_blade_model_id': self.blade_code_id.product_id.id, - 'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id, - 'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id, - 'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id, - 'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id, - 'diameter': self.functional_tool_diameter, - 'tool_grade': None, - 'machining_accuracy': None, - 'tool_length': self.tool_loading_length, - 'blade_number': None, - 'integral_blade_length': None, - 'effective_blade_length': self.effective_length, - 'max_life': None, - 'is_standard': self.whether_standard_tool, - 'applicable_range': None, - 'image': None, - } + desc_2 = self.get_desc_2(stock_lot) # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) self.env['sf.functional.tool.warning'].create({ @@ -335,7 +302,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'functional_cutting_tool_id': record_1.id }) - # 修改功能刀具组装信息 + # 修改功能刀具组装单信息 functional_tool_assembly.write(desc_1) if functional_tool_assembly.sf_machine_table_tool_changing_apply_id: @@ -352,6 +319,16 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 关闭弹出窗口 return {'type': 'ir.actions.act_window_close'} + def materials_must_be_judged(self): + """ + 功能刀具组装物料必填判断 + """ + if not self.integral_code_id and not self.blade_code_id: + raise ValidationError('【整体式刀具】和【刀片】必须填写一个!') + if self.blade_code_id: + if not self.bar_code_id and not self.pad_code_id: + raise ValidationError('【刀盘】和【刀杆】必须填写一个!') + def create_stocking_picking(self, stock_lot): """ 创建刀具组装入库单 @@ -413,7 +390,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'qty_done': 1.0, 'state': 'done' }) - return stock_move_id, stock_move_line_id def get_stock_lot_name(self): @@ -433,4 +409,49 @@ class FunctionalToolAssemblyOrder(models.TransientModel): else: m = int(stock_lot_id.name[-3:]) + 1 num = "%03d" % m - return code + str(num) \ No newline at end of file + return code + str(num) + + def get_desc_1(self, stock_lot): + return { + 'barcode_id': stock_lot.id, + 'integral_code_id': self.integral_code_id.id, + 'blade_code_id': self.blade_code_id.id, + 'bar_code_id': self.bar_code_id.id, + 'pad_code_id': self.pad_code_id.id, + 'handle_code_id': self.handle_code_id.id, + 'chuck_code_id': self.chuck_code_id.id, + 'coarse_middle_thin': self.coarse_middle_thin, + 'tool_loading_length': self.tool_loading_length, + 'new_former': self.new_former, + 'reference_length': self.reference_length, + 'cut_time': self.cut_time, + 'cut_length': self.cut_length, + 'cut_number': self.cut_number, + 'assemble_status': '1', + 'tool_loading_person': self.env.user.name, + 'tool_loading_time': fields.Datetime.now() + } + + def get_desc_2(self, stock_lot): + return { + 'barcode_id': stock_lot.id, + 'functional_tool_name_id': self.functional_tool_name_id.id, + 'mrs_cutting_tool_type_id': self.functional_tool_type_id.id, + 'cutting_tool_integral_model_id': self.integral_code_id.product_id.id, + 'cutting_tool_blade_model_id': self.blade_code_id.product_id.id, + 'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id, + 'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id, + 'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id, + 'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id, + 'diameter': self.functional_tool_diameter, + 'tool_grade': None, + 'machining_accuracy': None, + 'tool_length': self.tool_loading_length, + 'blade_number': None, + 'integral_blade_length': None, + 'effective_blade_length': self.effective_length, + 'max_life': None, + 'is_standard': self.whether_standard_tool, + 'applicable_range': None, + 'image': None, + } \ No newline at end of file From c885f3ce8c320a08f663231e6c8eba724a2f6e52 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Fri, 17 Nov 2023 17:30:37 +0800 Subject: [PATCH 02/14] =?UTF-8?q?1=E3=80=81=E8=AE=BE=E5=A4=87=E6=9C=BA?= =?UTF-8?q?=E5=BA=8A=E7=9A=84=E5=88=80=E4=BD=8D=E5=AF=B9=E8=B1=A1=E6=96=B0?= =?UTF-8?q?=E5=A2=9Ename=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=B9=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=B7=BB=E5=8A=A0=E5=80=BC=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E9=9C=80=E6=B1=82=E9=87=8D=E6=9E=84=E4=BA=86?= =?UTF-8?q?=E6=9C=BA=E5=BA=8A=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E9=87=8D=E6=9E=84=E6=9C=BA=E5=BA=8A=E6=8D=A2?= =?UTF-8?q?=E5=88=80=E5=BC=B9=E7=AA=97=E5=AF=B9=E8=B1=A1=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 7 + sf_tool_management/models/base.py | 142 +++++++++------- sf_tool_management/views/tool_base_views.xml | 166 ++++++++++--------- sf_tool_management/wizard/wizard.py | 102 ++++++------ sf_tool_management/wizard/wizard_view.xml | 52 ++++-- 5 files changed, 262 insertions(+), 207 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index b6961fda..4e3da687 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -911,5 +911,12 @@ class SfMaintenanceEquipmentTool(models.Model): alarm_value = fields.Char('报警值') used_value = fields.Char('已使用值') code = fields.Char('机床刀位号') + name = fields.Char('', compute='_compute_name') + + @api.depends('code') + def _compute_name(self): + for record in self: + if record.code: + record.name = record.code diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 31633de3..5f275253 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from odoo import fields, models, api from odoo import SUPERUSER_ID +from odoo.exceptions import ValidationError # class FunctionalCuttingToolEntity(models.Model): @@ -68,9 +69,9 @@ class FunctionalCuttingToolEntity(models.Model): related='cutting_tool_integral_model_id.suitable_machining_method_ids') 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_id') + 'rel_blade_tip_product_template_tool_entity', '刀尖特征', + domain=[('type', '=', '刀尖特征')], + related='cutting_tool_integral_model_id.blade_tip_characteristics_id') handle_type_ids = fields.Many2many('maintenance.equipment.image', 'rel_handle_product_template_tool_entity', '柄部类型', @@ -185,7 +186,7 @@ class FunctionalToolWarning(models.Model): return categories.browse(machine_table_name_ids) machine_tool_code = fields.Char('机台号', readonly=True, related='functional_tool_assembly_id.machine_tool_code') - cutting_tool_code = fields.Char('刀位号', readonly=True, related='functional_tool_assembly_id.cutter_spacing_code') + cutting_tool_code = fields.Char('刀位号', readonly=True) # idle_time = fields.Char('闲置时长', readonly=False) idle_time = fields.Char('闲置时长(h)', readonly=False) alarm_value = fields.Char('报警值', readonly=False) @@ -439,60 +440,73 @@ class InboundAndOutboundRecords(models.Model): class MachineTableToolChangingApply(models.Model): _name = 'sf.machine.table.tool.changing.apply' _description = '机床换刀申请' + _order = 'cutter_spacing_code_id' - name = fields.Many2one('maintenance.equipment', string='CNC机床', required=True, readonly=False, - group_expand='_read_group_names', domain=[('category_id.equipment_type', '=', '机床')]) + name = fields.Char('名称', related='maintenance_equipment_id.name', store=True) + maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', required=True, readonly=False, + group_expand='_read_group_names', + domain=[('category_id.equipment_type', '=', '机床')]) machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True, compute='_compute_machine_table_type_id') machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) - cutter_spacing_code = fields.Char(string='刀位号', readonly=False, required=True) + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=False, + required=True, + domain="[('equipment_id', '=', name)]") + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', + domain=[('product_id.name', '=', '功能刀具')]) + functional_tool_name = fields.Char(string='功能刀具名称') + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', + domain=[('name', '=', '功能刀具')]) + tool_position_interface_type = fields.Selection( + [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), + ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), + ('直装固定式', '直装固定式')], string='刀位接口型号') + diameter = fields.Integer(string='刀具直径(mm)', requried=True) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', requried=True) + max_lifetime_value = fields.Integer(string='最大寿命值(min)', requried=True) + alarm_value = fields.Integer(string='报警值(min)', requried=True) + used_value = fields.Integer(string='已使用值(min)', requried=True) + whether_standard_knife = fields.Boolean(string='是否标准刀', default=True) + extension__length = fields.Float(string='伸出长(mm)', requried=True) + effective_length = fields.Float(string='有效长(mm)', requried=True) - @api.depends('name') + functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警')], string='功能刀具状态', + default='正常') + + assembly_order_code = fields.Char(string='组装单编码', readonly=True) + applicant = fields.Char(string='申请人', readonly=True) + reason_for_applying = fields.Char(string='申请原因', readonly=True) + remark = fields.Char(string='备注说明', readonly=False) + + status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移'), ('3', '已组装')], + string='操作状态', default='0') + + sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装单', readonly=True) + + @api.depends('maintenance_equipment_id') def _compute_machine_table_type_id(self): for record in self: if record: - record.machine_table_type_id = record.name.category_id.id - record.machine_tool_code = record.name.code + record.machine_table_type_id = record.maintenance_equipment_id.category_id.id + record.machine_tool_code = record.maintenance_equipment_id.code else: record.machine_table_type_id = None record.machine_tool_code = None - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', - domain=[('product_id.name', '=', '功能刀具')]) - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', - domain=[('name', '=', '功能刀具')]) - functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - - diameter = fields.Char(string='直径(mm)', readonly=False) - coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False) - hilt_name = fields.Char(string='刀柄名称', readonly=False) - hilt_code = fields.Char(string='刀柄编号', readonly=False) - max_lifetime_value = fields.Char(string='最大寿命值', readonly=False) - alarm_value = fields.Char(string='报警值', readonly=False) - used_value = fields.Char(string='已使用值', readonly=False) - functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态', - default='正常', readonly=False) - - # replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True) - assembly_order_code = fields.Char(string='组装单编码', readonly=True) - replacement_tool_name_id = fields.Many2one('product.product', string='待换功能刀具名称', readonly=True) - replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型', - readonly=True) - replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], - string='粗/中/精(待换)', readonly=True) - new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) - applicant = fields.Char(string='申请人', readonly=True) - used_tool_time = fields.Datetime(string='用刀时间', readonly=True) - reason_for_applying = fields.Char(string='申请原因', readonly=True) - remark = fields.Char(string='备注说明', readonly=False) - - status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移'), ('3', '已组装')], string='操作状态', default='0') - - sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True) + @api.constrains("cutter_spacing_code_id") + def _check_cutter_spacing_code_id(self): + for obj in self: + records = self.env['sf.machine.table.tool.changing.apply'].search([ + ('maintenance_equipment_id', '=', obj.maintenance_equipment_id.id), + ('cutter_spacing_code_id', '=', obj.cutter_spacing_code_id.id)]) + if len(records) > 1: + raise ValidationError('该刀位号已存在,请重新选择!!!') @api.model def _read_group_names(self, categories, domain, order): - names = categories._search([('category_id.equipment_type', '=', '机床')], order=order, access_rights_uid=SUPERUSER_ID) + names = categories._search([('category_id.equipment_type', '=', '机床')], order=order, + access_rights_uid=SUPERUSER_ID) return categories.browse(names) @api.onchange('functional_tool_status') @@ -503,7 +517,7 @@ class MachineTableToolChangingApply(models.Model): """ # 更新数据到机台换刀申请界面 # todo 自动换刀申请条件需补充完善 - if self.functional_tool_status == '异常': + if self.functional_tool_status == '报警': self.env['sf.machine.table.tool.changing.apply'].search([ ('name', '=', self.name.id)]).write({ 'replacement_tool_name_id': self.functional_tool_name_id.id, @@ -528,7 +542,7 @@ class MachineTableToolChangingApply(models.Model): 'use_tool_time': self.used_tool_time, 'machine_tool_name': self.CNC_machine_table, 'machine_tool_code': self.machine_tool_code, - 'cutter_spacing_code': self.cutter_spacing_code, + 'cutter_spacing_code_id': self.cutter_spacing_code_id, }) def new_assembly_task(self, vals): @@ -646,8 +660,8 @@ class CAMWorkOrderProgramKnifePlan(models.Model): # 将计划执行状态改为执行中 self.env['sf.cam.work.order.program.knife.plan'].search( [('barcode_id', '=', self.barcode_id.id)]).write({ - 'plan_execute_status': '1', - 'applicant': self.env.user.name}) + 'plan_execute_status': '1', + 'applicant': self.env.user.name}) def revocation(self): """ @@ -661,10 +675,10 @@ class CAMWorkOrderProgramKnifePlan(models.Model): # 将计划执行状态改为待执行,同时清除申请人、功能刀具组装字段数据 self.env['sf.cam.work.order.program.knife.plan'].search( [('barcode_id', '=', self.barcode_id.id)]).write({ - 'plan_execute_status': '0', - 'applicant': None, - 'sf_functional_tool_assembly_id': None, - }) + 'plan_execute_status': '0', + 'applicant': None, + 'sf_functional_tool_assembly_id': None, + }) class FunctionalToolAssembly(models.Model): @@ -674,7 +688,8 @@ 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) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True) + functional_tool_name = fields.Char(string='功能刀具名称', requried=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') @@ -691,7 +706,8 @@ class FunctionalToolAssembly(models.Model): # 整体式刀具型号 integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', readonly=True) - cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', readonly=True) + cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', + readonly=True) integral_name = fields.Char('整体式刀具名称', readonly=True, compute='_compute_auto_fill') sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True) @@ -703,25 +719,29 @@ class FunctionalToolAssembly(models.Model): # 刀杆型号 bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', readonly=True) - cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', readonly=True) + cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', + readonly=True) bar_name = fields.Char('刀杆名称', readonly=True, compute='_compute_auto_fill') sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True) # 刀盘型号 pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', readonly=True) - cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', readonly=True) + cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', + readonly=True) pad_name = fields.Char('刀盘名称', readonly=True, compute='_compute_auto_fill') sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True) # 刀柄型号 handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', readonly=True) - cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', readonly=True) + cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', + readonly=True) handle_name = fields.Char('刀柄名称', readonly=True, compute='_compute_auto_fill') sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True) # 夹头型号 chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', readonly=True) - cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', readonly=True) + cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', + readonly=True) chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill') sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) @@ -797,7 +817,8 @@ class FunctionalToolAssembly(models.Model): production_line_name_id = fields.Many2one('sf.production.line', string='产线名称', readonly=False) machine_tool_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=True) machine_tool_code = fields.Char(string='机台号', readonly=True) - cutter_spacing_code = fields.Char(string='刀位号', readonly=True) + # cutter_spacing_code = fields.Char(string='刀位号', readonly=True) + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True) tool_loading_person = fields.Char(string='装刀人', readonly=True) tool_loading_time = fields.Datetime(string='装刀时间', readonly=True) @@ -806,7 +827,8 @@ class FunctionalToolAssembly(models.Model): remark = fields.Char(string='备注说明', readonly=True) check_box_1 = fields.Boolean(string='复选框', default=False, readonly=False) - sf_machine_table_tool_changing_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', '机床换刀申请', readonly=True) + sf_machine_table_tool_changing_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', '机床换刀申请', + readonly=True) sf_cam_work_order_program_knife_plan_id = fields.Many2one('sf.cam.work.order.program.knife.plan', 'CAM工单程序用刀计划', readonly=True, ) @@ -859,4 +881,4 @@ class FunctionalToolAssembly(models.Model): code = self._get_code(obj.loading_task_source) obj.assembly_order_code = code obj.name = code - return obj \ No newline at end of file + return obj diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 6b8e7982..b9dd679b 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -707,43 +707,58 @@ sf.machine.table.tool.changing.apply - - + + + - - - - - - + + + + + + + + + + - - - + + + + + + + + -

@@ -47,7 +48,8 @@

- + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - @@ -161,8 +165,8 @@ sf.functional.cutting.tool.entity - - + + @@ -177,7 +181,7 @@ - + 功能刀具列表 ir.actions.act_window sf.functional.cutting.tool.entity @@ -185,13 +189,13 @@ - + sf.functional.tool.warning.tree sf.functional.tool.warning - - + + @@ -217,7 +221,7 @@ sf.functional.tool.warning.form sf.functional.tool.warning - +

@@ -311,9 +315,9 @@ sf.functional.tool.warning - - - + + + @@ -330,7 +334,8 @@ - + @@ -344,12 +349,12 @@ - + 功能刀具实时分布 sf.real.time.distribution.of.functional.tools - + @@ -378,7 +383,7 @@ 功能刀具实时分布 sf.real.time.distribution.of.functional.tools - +

@@ -500,7 +505,7 @@ - + 功能刀具出入库记录 @@ -519,7 +524,7 @@ - + @@ -601,7 +606,7 @@ - + @@ -631,7 +636,7 @@ - + @@ -647,7 +652,7 @@ - + 出入库记录 sf.inbound.and.outbound.records @@ -701,18 +706,17 @@ - + 机床换刀申请 sf.machine.table.tool.changing.apply + - - - + @@ -722,18 +726,21 @@ + + - +

+ @@ -28,8 +29,8 @@ - - + + @@ -39,14 +40,14 @@ - + - + @@ -80,22 +81,30 @@ - +
+

+ +

+
+ - - + + + + + + + + - - - - - - - - - - + + + + + + + @@ -105,7 +114,8 @@ - + + From 8a1dfe14e6cb49d4526265ee12519403f250ae5c Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 21 Nov 2023 17:26:18 +0800 Subject: [PATCH 04/14] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E5=88=97=E8=A1=A8=E6=A8=A1=E5=9E=8B=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E6=9C=BA=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=A0=B9=E6=8D=AE=E6=8A=A5=E8=AD=A6=E5=80=BC=E5=92=8C?= =?UTF-8?q?=E6=9C=89=E6=95=88=E5=80=BC=E8=AE=A1=E7=AE=97=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=8A=B6=E6=80=81=EF=BC=8C=E9=87=8D=E6=9E=84=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=87=AA=E5=8A=A8=E6=8D=A2=E5=88=80=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=92=A4=E9=94=80=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9B3=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E5=8D=95=E6=A8=A1=E5=9E=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=A4=A7=E9=87=8F=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96tree=E8=A7=86=E5=9B=BE=E5=92=8Cform=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E7=9A=84=E5=B8=83=E5=B1=80=EF=BC=9B4=E3=80=81=E7=BB=84?= =?UTF-8?q?=E8=A3=85=E5=8D=95=E5=BC=B9=E7=AA=97=E6=A8=A1=E5=9E=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=A4=A7=E9=87=8F=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=A1=AE=E8=AE=A4=E7=BB=84=E8=A3=85=E6=8C=89=E9=94=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 195 ++++--- sf_tool_management/views/tool_base_views.xml | 90 ++- sf_tool_management/wizard/wizard.py | 146 +++-- sf_tool_management/wizard/wizard_view.xml | 563 ++++++++++--------- 4 files changed, 568 insertions(+), 426 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 4cbfbe06..1a7067cb 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +from datetime import timedelta + from odoo import fields, models, api from odoo import SUPERUSER_ID from odoo.exceptions import ValidationError @@ -14,13 +16,29 @@ class FunctionalCuttingToolEntity(models.Model): _description = '功能刀具列表' # code = fields.Char('序列号') + name = fields.Char(related='functional_tool_name_id.name') + functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - 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.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) + functional_tool_diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) + new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) + tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True) + functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True) + effective_length = fields.Float(string='有效长(mm)', readonly=True) + tool_room_num = fields.Integer(string='刀具房数量') + line_edge_knife_library_num = fields.Integer(string='线边刀库数量') + machine_knife_library_num = fields.Integer(string='机内刀库数量') + max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) + alarm_value = fields.Integer(string='报警值(min)', readonly=True) + used_value = fields.Integer(string='已使用值(min)', readonly=True) + functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], + string='状态', store=True, default='正常') + @api.model def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order): mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) @@ -175,7 +193,7 @@ class FunctionalToolWarning(models.Model): self.is_standard = self.functional_cutting_tool_id.is_standard # 功能刀具预警 特有字段 - outbound_time = fields.Datetime('出库时间', readonly=True, related='functional_tool_assembly_id.receive_time') + outbound_time = fields.Datetime('出库时间', readonly=True) on_board_time = fields.Datetime('上机时间', readonly=False) machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=True, group_expand='_read_group_machine_table_name_ids') @@ -462,18 +480,18 @@ class MachineTableToolChangingApply(models.Model): tool_position_interface_type = fields.Selection( [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), - ('直装固定式', '直装固定式')], string='刀位接口型号', requried=True) - diameter = fields.Integer(string='刀具直径(mm)', requried=True) - knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', requried=True) - max_lifetime_value = fields.Integer(string='最大寿命值(min)', requried=True) - alarm_value = fields.Integer(string='报警值(min)', requried=True) - used_value = fields.Integer(string='已使用值(min)', requried=True) + ('直装固定式', '直装固定式')], string='刀位接口型号', required=True) + diameter = fields.Integer(string='刀具直径(mm)', ) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') + max_lifetime_value = fields.Integer(string='最大寿命值(min)') + alarm_value = fields.Integer(string='报警值(min)') + used_value = fields.Integer(string='已使用值(min)') whether_standard_knife = fields.Boolean(string='是否标准刀', default=True) - extension_length = fields.Float(string='伸出长(mm)', requried=True) - effective_length = fields.Float(string='有效长(mm)', requried=True) + extension_length = fields.Float(string='伸出长(mm)') + effective_length = fields.Float(string='有效长(mm)') - functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警')], string='功能刀具状态', - default='正常') + functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警')], string='功能刀具状态', store=True, + default='正常', compute='_compute_functional_tool_status') assembly_order_code = fields.Char(string='组装单编码', readonly=True) applicant = fields.Char(string='申请人', readonly=True) @@ -485,6 +503,14 @@ class MachineTableToolChangingApply(models.Model): sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装单', readonly=True) + @api.depends('alarm_value', 'used_value') + def _compute_functional_tool_status(self): + for record in self: + if record.alarm_value <= record.used_value: + record.functional_tool_status = '报警' + else: + record.functional_tool_status = '正常' + @api.depends('maintenance_equipment_id') def _compute_machine_table_type_id(self): for record in self: @@ -511,54 +537,57 @@ class MachineTableToolChangingApply(models.Model): names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) return categories.browse(names) - @api.onchange('functional_tool_status') + @api.constrains('functional_tool_status') def automation_apply_for_tool_change(self): """ 自动申请换刀 :return: """ # 更新数据到机台换刀申请界面 - # todo 自动换刀申请条件需补充完善 - if self.functional_tool_status == '报警': - self.env['sf.machine.table.tool.changing.apply'].search([ - ('name', '=', self.name.id)]).write({ - 'replacement_tool_name_id': self.functional_tool_name_id.id, - 'replacement_tool_type_id': self.functional_tool_type_id.id, - 'replacement_tool_coarse_middle_thin': self.coarse_middle_thin, - 'new_former': '0', - 'applicant': '自动申请', - 'used_tool_time': fields.Datetime.now(), - 'reason_for_applying': '功能刀具状态异常', - 'remark': None, - 'status': '1' - }) + if self.functional_tool_status == '报警' and self.sf_functional_tool_assembly_id == False: + machine_table_tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( + [('maintenance_equipment_id', '=', self.maintenance_equipment_id.id), + ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id) + ]) # 新建组装任务 - self.env['sf.functional.tool.assembly'].create({ - 'name': self.functional_tool_name_id, + sf_functional_tool_assembly = self.env['sf.functional.tool.assembly'].create({ + 'functional_tool_name': self.functional_tool_name, 'functional_tool_type_id': self.functional_tool_type_id.id, 'functional_tool_diameter': self.diameter, + 'knife_tip_r_angle': self.knife_tip_r_angle, + 'coarse_middle_thin': '3', + 'new_former': '0', + 'functional_tool_length': self.extension_length, + 'effective_length': self.effective_length, 'loading_task_source': '1', - 'applicant': '自动申请', - 'reason_for_applying': '功能刀具状态异常', - 'use_tool_time': self.used_tool_time, - 'machine_tool_name': self.CNC_machine_table, - 'machine_tool_code': self.machine_tool_code, - 'cutter_spacing_code_id': self.cutter_spacing_code_id, + 'use_tool_time': fields.Datetime.now() + timedelta(hours=4), + 'production_line_name_id': self.production_line_id.id, + 'machine_tool_name_id': self.maintenance_equipment_id.id, + 'applicant': self.applicant, + 'apply_time': fields.Datetime.now(), + 'cutter_spacing_code_id': self.cutter_spacing_code_id.id, + 'whether_standard_knife': self.whether_standard_knife, + 'reason_for_applying': '机台报警自动换刀', + 'sf_machine_table_tool_changing_apply_id': self.id }) - def new_assembly_task(self, vals): - """ - 新建组装任务 - :param vals: - :return: - """ - # 增加设置直径的值 - tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( - [('name', '=', vals['name'])]) - vals['functional_tool_diameter'] = tool_changing_apply.diameter + machine_table_tool_changing_apply.write( + {'status': '1', + 'sf_functional_tool_assembly_id': sf_functional_tool_assembly}) - self.env['sf.functional.tool.assembly'].create(vals) + # def new_assembly_task(self, vals): + # """ + # 新建组装任务 + # :param vals: + # :return: + # """ + # # 增加设置直径的值 + # tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( + # [('name', '=', vals['name'])]) + # vals['functional_tool_diameter'] = tool_changing_apply.diameter + # + # self.env['sf.functional.tool.assembly'].create(vals) def revocation_1(self): """ @@ -567,22 +596,16 @@ class MachineTableToolChangingApply(models.Model): """ # 撤回功能刀具组装创建的任务 self.env['sf.functional.tool.assembly'].search( - [('assembly_order_code', '=', self.assembly_order_code), + [('id', '=', self.sf_functional_tool_assembly_id.id), ('loading_task_source', '=', '1')]).unlink() # 撤回数据更新 - self.env['sf.machine.table.tool.changing.apply'].search([('name', '=', self.name.id)]).write({ - 'replacement_tool_name_id': None, - 'replacement_tool_type_id': None, - 'replacement_tool_coarse_middle_thin': None, - 'new_former': None, - 'applicant': None, - 'used_tool_time': None, - 'reason_for_applying': None, - 'remark': None, - 'status': '0', - 'sf_functional_tool_assembly_id': None, - }) + self.env['sf.machine.table.tool.changing.apply'].search( + [('maintenance_equipment_id', '=', self.maintenance_equipment_id.id), + ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id)]).write( + {'status': '0', + 'sf_functional_tool_assembly_id': None + }) def revocation_2(self): """ @@ -590,9 +613,7 @@ class MachineTableToolChangingApply(models.Model): :return: """ self.env['sf.machine.table.tool.changing.apply'].search( - [('name', '=', self.name.id)]).write({ - 'status': '0' - }) + [('name', '=', self.name.id)]).write({'status': '0'}) class CAMWorkOrderProgramKnifePlan(models.Model): @@ -688,7 +709,12 @@ class FunctionalToolAssembly(models.Model): _description = '功能刀具组装单' _order = 'use_tool_time asc' - name = fields.Char(string='名称', readonly=True) + @api.depends('functional_tool_name') + def _compute_name(self): + for obj in self: + obj.name = obj.functional_tool_name + + name = fields.Char(string='名称', readonly=True, compute='_compute_name') assembly_order_code = fields.Char(string='编码', readonly=True) functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True) @@ -705,13 +731,13 @@ class FunctionalToolAssembly(models.Model): loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')], string='装刀任务来源', readonly=True) use_tool_time = fields.Datetime(string='用刀时间', readonly=True) - production_line_name_id = fields.Many2one('sf.production.line', string='申请产线', readonly=False) + production_line_name_id = fields.Many2one('sf.production.line', string='申请产线', readonly=True) machine_tool_name_id = fields.Many2one('maintenance.equipment', string='申请机台', readonly=True) machine_tool_code = fields.Char(string='机台号', readonly=True) applicant = fields.Char(string='申请人', readonly=True) apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True) - assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', - default='0', readonly=True) + assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0', + readonly=True) cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True) whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True) reason_for_applying = fields.Char(string='申请原因', readonly=True) @@ -819,33 +845,29 @@ class FunctionalToolAssembly(models.Model): barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True) after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', - string='组装后功能刀具类型', readonly=True, - group_expand='_read_group_functional_tool_type_ids') - after_assembly_functional_tool_diameter = fields.Integer(string='功能刀具直径(mm)', readonly=True) - after_assembly_knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) - after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) - cut_time = fields.Char(string='已切削时间', readonly=True) - cut_length = fields.Char(string='已切削长度(mm)', readonly=True) - cut_number = fields.Char(string='已切削次数', readonly=True) + string='组装后功能刀具类型', readonly=True) + after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)', readonly=True) + after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True) + after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True) + cut_time = fields.Integer(string='已切削时间(min)', readonly=True) + cut_length = fields.Float(string='已切削长度(mm)', readonly=True) + cut_number = fields.Integer(string='已切削次数', readonly=True) - after_assembly_whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True) + after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True, readonly=True) after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], - string='粗/中/精', readonly=True) - after_assembly_max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) - after_assembly_alarm_value = fields.Integer(string='报警值(min)', readonly=True) - after_assembly_used_value = fields.Integer(string='已使用值(min)', readonly=True) - after_assembly_tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True) - after_assembly_functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True) - after_assembly_effective_length = fields.Float(string='有效长(mm)', readonly=True) + string='组装后粗/中/精', readonly=True) + after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)', readonly=True) + after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)', readonly=True) + after_assembly_used_value = fields.Integer(string='组装后已使用值(min)', readonly=True) + after_assembly_tool_loading_length = fields.Float(string='组装后装刀长(mm)', readonly=True) + after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', readonly=True) + after_assembly_effective_length = fields.Float(string='组装后有效长(mm)', readonly=True) L_D_number = fields.Float(string='L/D值(mm)', readonly=True) hiding_length = fields.Float(string='避空长(mm)', readonly=True) functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False) - # cutter_spacing_code = fields.Char(string='刀位号', readonly=True) tool_loading_person = fields.Char(string='装刀人', readonly=True) tool_loading_time = fields.Datetime(string='装刀时间', readonly=True) - receive_person = fields.Char(string='领用人', readonly=True) - receive_time = fields.Datetime(string='领用出库时间', readonly=True) remark = fields.Char(string='备注说明', readonly=True) check_box_1 = fields.Boolean(string='复选框', default=False, readonly=False) @@ -902,5 +924,4 @@ class FunctionalToolAssembly(models.Model): if obj.loading_task_source: code = self._get_code(obj.loading_task_source) obj.assembly_order_code = code - obj.name = code return obj diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 217400b9..b07fe225 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -765,7 +765,6 @@ 'default_replacement_knife_tip_r_angle': knife_tip_r_angle, 'default_replacement_max_lifetime_value': max_lifetime_value, 'default_replacement_alarm_value': alarm_value, - 'default_replacement_used_value': used_value, 'default_replacement_whether_standard_knife': whether_standard_knife, 'default_replacement_extension_length': extension_length, 'default_replacement_effective_length': effective_length, @@ -842,7 +841,6 @@ 'default_replacement_knife_tip_r_angle': knife_tip_r_angle, 'default_replacement_max_lifetime_value': max_lifetime_value, 'default_replacement_alarm_value': alarm_value, - 'default_replacement_used_value': used_value, 'default_replacement_whether_standard_knife': whether_standard_knife, 'default_replacement_extension_length': extension_length, 'default_replacement_effective_length': effective_length, @@ -880,6 +878,7 @@

+ @@ -1177,16 +1202,34 @@ - - - - - - + + + + + + + + + + + + + + + + + + @@ -1291,7 +1334,8 @@ - 、 + +
@@ -1299,11 +1343,9 @@ - - diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 053ba39a..3c17bf47 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -32,21 +32,21 @@ class ToolChangeRequirementInformation(models.TransientModel): effective_length = fields.Float(string='有效长(mm)', readonly=True) # 待换功能刀具信息 - replacement_tool_name = fields.Char(string='待换功能刀具名称') + replacement_tool_name = fields.Char(string='待换功能刀具名称', required=True) replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型') - replacement_diameter = fields.Integer(string='待换刀具直径(mm)', requried=True) - replacement_knife_tip_r_angle = fields.Float(string='待换刀具刀尖R角(mm)', requried=True) - replacement_tool_setting_length = fields.Float(string='待换刀具装刀长(mm)', requried=True) - replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)', requried=True) - replacement_effective_length = fields.Float(string='待换刀具有效长(mm)', requried=True) + replacement_diameter = fields.Integer(string='待换刀具直径(mm)') + replacement_knife_tip_r_angle = fields.Float(string='待换刀具刀尖R角(mm)') + replacement_tool_setting_length = fields.Float(string='待换刀具装刀长(mm)') + replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)') + replacement_effective_length = fields.Float(string='待换刀具有效长(mm)') replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='待换刀具粗/中/精', default='3') - replacement_max_lifetime_value = fields.Integer(string='待换刀具最大寿命值(min)', requried=True) - replacement_alarm_value = fields.Integer(string='待换刀具报警值(min)', requried=True) - replacement_used_value = fields.Integer(string='待换刀具已使用值(min)', requried=True) + replacement_max_lifetime_value = fields.Integer(string='待换刀具最大寿命值(min)') + replacement_alarm_value = fields.Integer(string='待换刀具报警值(min)') + replacement_used_value = fields.Integer(string='待换刀具已使用值(min)') new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', default='0') - replacement_whether_standard_knife = fields.Boolean(string='待换刀具是否标准刀', default=True, requried=True) + replacement_whether_standard_knife = fields.Boolean(string='待换刀具是否标准刀', default=True) used_tool_time = fields.Datetime(string='用刀时间', default=lambda self: fields.Datetime.now() + timedelta(hours=4)) applicant = fields.Char(string='申请人', default=lambda self: self.env.user.name, readonly=True) @@ -83,7 +83,8 @@ class ToolChangeRequirementInformation(models.TransientModel): 'apply_time': fields.Datetime.now(), 'cutter_spacing_code_id': self.cutter_spacing_code_id.id, 'whether_standard_knife': self.whether_standard_knife, - 'reason_for_applying': self.reason_for_applying + 'reason_for_applying': self.reason_for_applying, + 'sf_machine_table_tool_changing_apply_id': record.id }) print('sf_functional_tool_assembly:', sf_functional_tool_assembly) # 修改机床换刀申请状态 @@ -129,7 +130,7 @@ class ToolTransferRequestInformation(models.TransientModel): ('线边刀库', '线边刀库'), ('刀具房', '刀具房')], string='转移到:', default='线边刀库') new_cnc_machine_table_id = fields.Many2one('sf.machine_tool', string='机床名称') - new_production_line_id = fields.Many2one('sf.production.line', string='生产线') + new_production_line_id = fields.Many2one('sf.production.line', string='目标生产线') new_machine_tool_code = fields.Char(string='机床号') new_cutter_spacing_code = fields.Char(string='目标刀位号') @@ -153,21 +154,33 @@ class FunctionalToolAssemblyOrder(models.TransientModel): _inherit = ["barcodes.barcode_events_mixin"] _description = '功能刀具组装单' - # 功能刀具申请信息 - machine_tool_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=True) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True) + functional_tool_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') + functional_tool_diameter = fields.Integer(string='功能刀具直径(mm)', readonly=True) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) + new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) + tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True) + functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True) + effective_length = fields.Float(string='有效长(mm)', readonly=True) + loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')], + string='装刀任务来源', readonly=True) + use_tool_time = fields.Datetime(string='用刀时间', readonly=True) + production_line_name_id = fields.Many2one('sf.production.line', string='申请产线', readonly=True) + machine_tool_name_id = fields.Many2one('maintenance.equipment', string='申请机台', readonly=True) machine_tool_code = fields.Char(string='机台号', readonly=True) - cutter_spacing_code = fields.Char(string='刀位号', readonly=True) - # 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) - functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True) - functional_tool_length = fields.Char(string='功能刀具伸出长(mm)', readonly=True) - effective_length = fields.Char(string='有效长(mm)', readonly=True) - functional_tool_diameter = fields.Char(string='功能刀具直径(mm)', readonly=True) - tool_included_angle = fields.Char(string='刀尖角(R角)', readonly=True) - functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=True) - required_cutting_time = fields.Char(string='需切削时长', readonly=True) - whether_standard_tool = fields.Boolean(string='是否标准刀', readonly=True) + applicant = fields.Char(string='申请人', readonly=True) + apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True) + assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0', + readonly=True) + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True) + whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True) + reason_for_applying = fields.Char(string='申请原因', readonly=True) + max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) + alarm_value = fields.Integer(string='报警值(min)', readonly=True) + used_value = fields.Integer(string='已使用值(min)', readonly=True) # 功能刀具组装信息 # 整体式刀具型号 @@ -294,13 +307,30 @@ class FunctionalToolAssemblyOrder(models.TransientModel): record.chuck_name = None record.sf_tool_brand_id_6 = None - coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', default='1') - tool_loading_length = fields.Char(string='装刀长') - new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', required=True, default='0') - reference_length = fields.Char(string='参考伸出长') - cut_time = fields.Char(string='已切削时间') - cut_length = fields.Char(string='已切削长度') - cut_number = fields.Char(string='已切削次数') + # 组装功能刀具参数信息 + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号') + after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', required=True) + after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', + string='组装后功能刀具类型') + after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)') + after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)') + after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧') + cut_time = fields.Integer(string='已切削时间(min)') + cut_length = fields.Float(string='已切削长度(mm)') + cut_number = fields.Integer(string='已切削次数') + + after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True) + after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='组装后粗/中/精') + after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)') + after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)') + after_assembly_used_value = fields.Integer(string='组装后已使用值(min)') + after_assembly_tool_loading_length = fields.Float(string='组装后装刀长(mm)') + after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)') + after_assembly_effective_length = fields.Float(string='组装后有效长(mm)') + L_D_number = fields.Float(string='L/D值(mm)') + hiding_length = fields.Float(string='避空长(mm)') + + functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False) def functional_tool_assembly(self): """ @@ -319,26 +349,26 @@ class FunctionalToolAssemblyOrder(models.TransientModel): desc_1 = self.get_desc_1(stock_lot) 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), + ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id), ('assemble_status', '=', '0'), ]) # 创建功能刀具列表记录 # 封装功能刀具数据 - desc_2 = self.get_desc_2(stock_lot) - # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 - record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) - self.env['sf.functional.tool.warning'].create({ - 'functional_cutting_tool_id': record_1.id, - 'functional_tool_assembly_id': functional_tool_assembly.id, - 'machine_table_name_id': self.machine_tool_name_id.id, - }) - self.env['sf.real.time.distribution.of.functional.tools'].create({ - 'functional_cutting_tool_id': record_1.id - }) - self.env['sf.inbound.and.outbound.records.of.functional.tools'].create({ - 'functional_cutting_tool_id': record_1.id - }) + # desc_2 = self.get_desc_2(stock_lot) + # # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 + # record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) + # self.env['sf.functional.tool.warning'].create({ + # 'functional_cutting_tool_id': record_1.id, + # 'functional_tool_assembly_id': functional_tool_assembly.id, + # 'machine_table_name_id': self.machine_tool_name_id.id, + # }) + # self.env['sf.real.time.distribution.of.functional.tools'].create({ + # 'functional_cutting_tool_id': record_1.id + # }) + # self.env['sf.inbound.and.outbound.records.of.functional.tools'].create({ + # 'functional_cutting_tool_id': record_1.id + # }) # 修改功能刀具组装单信息 functional_tool_assembly.write(desc_1) @@ -458,13 +488,25 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'pad_code_id': self.pad_code_id.id, 'handle_code_id': self.handle_code_id.id, 'chuck_code_id': self.chuck_code_id.id, - 'coarse_middle_thin': self.coarse_middle_thin, - 'tool_loading_length': self.tool_loading_length, - 'new_former': self.new_former, - 'reference_length': self.reference_length, + + 'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name, + 'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id, + 'after_assembly_functional_tool_diameter': self.after_assembly_functional_tool_diameter, + 'after_assembly_knife_tip_r_angle': self.after_assembly_knife_tip_r_angle, + 'after_assembly_new_former': self.after_assembly_new_former, 'cut_time': self.cut_time, 'cut_length': self.cut_length, 'cut_number': self.cut_number, + 'after_assembly_whether_standard_knife': self.after_assembly_whether_standard_knife, + 'after_assembly_coarse_middle_thin': self.after_assembly_coarse_middle_thin, + 'after_assembly_max_lifetime_value': self.after_assembly_max_lifetime_value, + 'after_assembly_alarm_value': self.after_assembly_alarm_value, + 'after_assembly_used_value': self.after_assembly_used_value, + 'after_assembly_tool_loading_length': self.after_assembly_tool_loading_length, + 'after_assembly_functional_tool_length': self.after_assembly_functional_tool_length, + 'after_assembly_effective_length': self.after_assembly_effective_length, + 'L_D_number': self.L_D_number, + 'hiding_length': self.hiding_length, 'assemble_status': '1', 'tool_loading_person': self.env.user.name, 'tool_loading_time': fields.Datetime.now() diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index caba3017..35db780f 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -1,67 +1,68 @@ - + - 换刀需求信息 - sf.tool.change.requirement.information - - - -
-

- -

-
+ 换刀需求信息 + sf.tool.change.requirement.information + + + +
+

+ +

+
+ - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + -
-
-
- -
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + @@ -74,63 +75,71 @@ - + - 刀具转移申请信息 - sf.tool.transfer.request.information - -
- -
-

- -

-
+ 刀具转移申请信息 + sf.tool.transfer.request.information + + + +
+

+ +

+
+ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + -
-
-
- -
+ + + + + + + + + + + + + + + + + + +
+
+
+ +
@@ -143,187 +152,215 @@ - + - 功能刀具组装单 - sf.functional.tool.assembly.order - -
- - + 功能刀具组装单 + sf.functional.tool.assembly.order + + + +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
- - - - - - + + + - - - - - - - + + + + + + + + + + - - - -
- -
+ +
+ +
+ - - - - - - - - - - - - - - + - -
- -
+ - - - + - - - - - - - - - - + + + + + - -
- -
+
+ +
+ +
+ - - - - - - - - - - - - - - + - -
- -
+ - - - + - - - - - - - - - - + + + + + - -
- -
+
+ +
+ +
+ - - - - - - - - - - - - - - + - -
- -
+ - - - + - - - - - - - - - - + + + + + - +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+
- - - - - - - - - - - - + + + + + + + + + + + -
-
-
- -
+ + + + + + + + + + + + +
+
+
+
+ +
From e6bb5db0e139f635e77d56f5edadfff3706b7e12 Mon Sep 17 00:00:00 2001 From: "qihao.gong@jikimo.com" Date: Tue, 21 Nov 2023 17:42:36 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E5=BC=80=E5=8F=91sf=E5=88=B6=E9=80=A0?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=9D=83=E9=99=90=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/commons/__init__.py | 2 +- sf_base/commons/common.py | 4 +- sf_base/security/group_security.xml | 33 +++++++++++++ sf_maintenance/models/sf_maintenance.py | 30 ++++++++---- sf_manufacturing/__manifest__.py | 5 +- sf_manufacturing/models/product_template.py | 4 +- sf_manufacturing/models/quality.py | 46 +++++++++++++------ sf_manufacturing/models/res_user.py | 2 +- sf_manufacturing/models/stock.py | 22 +++++---- sf_manufacturing/security/ir.model.access.csv | 27 ++++++++--- sf_manufacturing/views/mrp_views_menus.xml | 33 +++++++++++++ sf_sale/models/auto_quatotion_common.py | 2 +- sf_sale/models/quick_easy_order.py | 4 +- 13 files changed, 162 insertions(+), 52 deletions(-) create mode 100644 sf_manufacturing/views/mrp_views_menus.xml diff --git a/sf_base/commons/__init__.py b/sf_base/commons/__init__.py index d89945c1..e4193cf0 100644 --- a/sf_base/commons/__init__.py +++ b/sf_base/commons/__init__.py @@ -1 +1 @@ -from. import common +from . import common diff --git a/sf_base/commons/common.py b/sf_base/commons/common.py index a1aed3c2..05a2143f 100644 --- a/sf_base/commons/common.py +++ b/sf_base/commons/common.py @@ -8,7 +8,7 @@ class Common(models.Model): _name = 'sf.sync.common' _description = u'公用类' - def get_headers(self,token, secret_key): + def get_headers(self, token, secret_key): ''' 获取requests中的heardes参数 ''' @@ -19,5 +19,3 @@ class Common(models.Model): 'TIMESTAMP': str(timestamp), 'checkstr': check_sf_str} return headers - - diff --git a/sf_base/security/group_security.xml b/sf_base/security/group_security.xml index b8668782..770fe378 100644 --- a/sf_base/security/group_security.xml +++ b/sf_base/security/group_security.xml @@ -1,4 +1,37 @@ + + 制造普通用户 + + + + 制造管理用户 + + + + + + 机床操作岗 + + + + + 刀具组装岗 + + + + + 工件装夹岗 + + + + + + 生产总监 + + + + + \ No newline at end of file diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index bf58c8f2..2e546366 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -12,7 +12,8 @@ class SfMaintenanceEquipmentCategory(models.Model): _inherit = 'maintenance.equipment.category' _description = '设备类别' - equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], string='类型', default='机床') + equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')] + , string='类型', default='机床') class SfMaintenanceEquipment(models.Model): @@ -64,7 +65,8 @@ class SfMaintenanceEquipment(models.Model): MTcode = fields.Char("编码", default=get_no) created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) - equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], compute='_compute_category_id') + equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')] + , compute='_compute_category_id') @api.depends('category_id') def _compute_category_id(self): @@ -278,7 +280,8 @@ class SfMaintenanceEquipment(models.Model): detect_y_axis = fields.Char('检测Y轴') detect_z_axis = fields.Char('检测Z轴') detect_precision = fields.Char('测量精度') - detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), ('激光干涉仪', '激光干涉仪')], string='测量方式') + detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), + ('激光干涉仪', '激光干涉仪')], string='测量方式') detect_resolution = fields.Char('分辨率') detect_load_weight_max = fields.Char('最大负载重量') detect_weight = fields.Char('本体总重量') @@ -304,13 +307,15 @@ class SfMaintenanceEquipment(models.Model): robot_load_weight_max = fields.Char('最大负载重量') robot_weight = fields.Char('本体总重量') robot_repeatable_positioning_accuracy = fields.Char('重复定位精度') - robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'), ('7轴', '7轴'), ('8轴', '8轴')], string='轴数') + robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'), + ('7轴', '7轴'), ('8轴', '8轴')], string='轴数') axis_ids = fields.One2many('sf.robot.axis.num', 'equipment_id', string='动作范围') robot_track_dimensions_L = fields.Char('轨道尺寸(长)') robot_track_dimensions_W = fields.Char('轨道尺寸(宽)') robot_track_dimensions_H = fields.Char('轨道尺寸(高)') robot_drive_mode = fields.Char('驱动方式') - robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], string='安装方式') + robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], + string='安装方式') robot_operating_temperature = fields.Char('机器人环境温度') robot_operating_humidity = fields.Char('机器人环境湿度') @@ -433,7 +438,8 @@ class SfMaintenanceEquipment(models.Model): if next_maintenance_todo and last_maintenance_done: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date - # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future + # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than + # 2 times the period and next request is in the future # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta( days=equipment.period) * 2 and next_maintenance_todo.request_date > date_now: @@ -445,7 +451,8 @@ class SfMaintenanceEquipment(models.Model): elif next_maintenance_todo: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - date_now - # If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request + # If next maintenance to do is in the future, and in more than 2 times the period, we insert + # an new request # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.period) * 2: next_date = date_now + timedelta(days=equipment.period) @@ -475,7 +482,8 @@ class SfMaintenanceEquipment(models.Model): if next_maintenance_todo and last_maintenance_done: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date - # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future + # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 + # times the period and next request is in the future # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta( days=equipment.overhaul_period) * 2 and next_maintenance_todo.request_date > date_now: @@ -487,7 +495,8 @@ class SfMaintenanceEquipment(models.Model): elif next_maintenance_todo: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - date_now - # If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request + # If next maintenance to do is in the future, and in more than 2 times the period, we insert + # an new request # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.overhaul_period) * 2: next_date = date_now + timedelta(days=equipment.overhaul_period) @@ -577,7 +586,8 @@ class SfMaintenanceEquipment(models.Model): if not next_requests: equipment._create_new_request1(equipment.overhaul_date) - image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', domain="[('type', '=', '加工能力')]") + image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', + domain="[('type', '=', '加工能力')]") class SfRobotAxisNum(models.Model): diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 9800bf5d..0b69f59e 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -10,11 +10,12 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['mrp_workorder', 'sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'stock'], + 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'stock'], 'data': [ 'data/stock_data.xml', 'security/group_security.xml', 'security/ir.model.access.csv', + 'views/mrp_views_menus.xml', 'views/mrp_production_addional_change.xml', # 'views/mrp_maintenance_views.xml', 'views/mrp_routing_workcenter_view.xml', @@ -23,7 +24,7 @@ 'views/mrp_workorder_view.xml', 'views/model_type_view.xml', 'views/sf_maintenance_equipment.xml', - # 'views/kanban_change.xml' + ], 'assets': { diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 73d3d4aa..ea0841ad 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -3,8 +3,8 @@ 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 +#from OCC.Extend.DataExchange import read_step_file +#from OCC.Extend.DataExchange import write_stl_file import logging import base64 import hashlib diff --git a/sf_manufacturing/models/quality.py b/sf_manufacturing/models/quality.py index a0797b61..1bb75c11 100644 --- a/sf_manufacturing/models/quality.py +++ b/sf_manufacturing/models/quality.py @@ -97,12 +97,15 @@ class QualityPoint(models.Model): component_ids = fields.One2many('product.product', compute='_compute_component_ids') product_ids = fields.Many2many( default=_default_product_ids, - domain="operation_id and [('id', 'in', bom_product_ids)] or [('type', 'in', ('product', 'consu')), '|', ('company_id', '=', False), ('company_id', '=', company_id)]") + domain="operation_id and [('id', 'in', bom_product_ids)] or" + " [('type', 'in', ('product', 'consu'))," + " '|', ('company_id', '=', False), ('company_id', '=', company_id)]") bom_product_ids = fields.One2many('product.product', compute="_compute_bom_product_ids") test_type_id = fields.Many2one( 'quality.point.test_type', domain="[('allow_registration', '=', operation_id and is_workorder_step)]") - test_report_type = fields.Selection([('pdf', 'PDF'), ('zpl', 'ZPL')], string="Report Type", default="pdf", required=True) + test_report_type = fields.Selection([('pdf', 'PDF'), ('zpl', 'ZPL')], string="Report Type", + default="pdf", required=True) source_document = fields.Selection( selection=[('operation', 'Specific Page of Operation Worksheet'), ('step', 'Custom')], string="Step Document", @@ -125,20 +128,23 @@ class QualityPoint(models.Model): points_for_workorder_step = self.filtered(lambda p: p.operation_id and p.bom_id) for point in points_for_workorder_step: bom_product_ids = point.bom_id.product_id or point.bom_id.product_tmpl_id.product_variant_ids - point.bom_product_ids = bom_product_ids.filtered(lambda p: not p.company_id or p.company_id == point.company_id._origin) + point.bom_product_ids = bom_product_ids.filtered(lambda p: not p.company_id or + p.company_id == point.company_id._origin) @api.depends('product_ids', 'test_type_id', 'is_workorder_step') def _compute_component_ids(self): self.component_ids = False for point in self: - if not point.is_workorder_step or not self.bom_id or point.test_type not in ('register_consumed_materials', 'register_byproducts'): + if not point.is_workorder_step or not self.bom_id or point.test_type not in ('register_consumed_materials', + 'register_byproducts'): point.component_id = None continue if point.test_type == 'register_byproducts': point.component_ids = point.bom_id.byproduct_ids.product_id else: bom_products = point.bom_id.product_id or point.bom_id.product_tmpl_id.product_variant_ids - # If product_ids is set the step will exist only for these product variant then we can filter out for the bom explode + # If product_ids is set the step will exist only for these product variant then we can filter + # out for the bom explode if point.product_ids: bom_products &= point.product_ids._origin @@ -183,7 +189,8 @@ class QualityCheck(models.Model): workorder_id = fields.Many2one( 'mrp.workorder', 'Operation', check_company=True) - workcenter_id = fields.Many2one('mrp.workcenter', related='workorder_id.workcenter_id', store=True, readonly=True) # TDE: necessary ? + workcenter_id = fields.Many2one('mrp.workcenter', related='workorder_id.workcenter_id', store=True, + readonly=True) # TDE: necessary ? production_id = fields.Many2one( 'mrp.production', 'Production Order', check_company=True) @@ -201,12 +208,14 @@ class QualityCheck(models.Model): component_uom_id = fields.Many2one('uom.uom', related='move_id.product_uom', readonly=True) qty_done = fields.Float('Done', digits='Product Unit of Measure') - finished_lot_id = fields.Many2one('stock.lot', 'Finished Lot/Serial', related='production_id.lot_producing_id', store=True) + finished_lot_id = fields.Many2one('stock.lot', 'Finished Lot/Serial', related='production_id.lot_producing_id', + store=True) additional = fields.Boolean('Register additional product', compute='_compute_additional') component_tracking = fields.Selection(related='component_id.tracking', string="Is Component Tracked") # Workorder specific fields - component_remaining_qty = fields.Float('Remaining Quantity for Component', compute='_compute_component_data', digits='Product Unit of Measure') + component_remaining_qty = fields.Float('Remaining Quantity for Component', compute='_compute_component_data', + digits='Product Unit of Measure') component_qty_to_do = fields.Float(compute='_compute_component_qty_to_do') is_user_working = fields.Boolean(related="workorder_id.is_user_working") consumption = fields.Selection(related="workorder_id.consumption") @@ -241,7 +250,8 @@ class QualityCheck(models.Model): super()._compute_title() for check in self: if not check.point_id or check.component_id: - check.title = '{} "{}"'.format(check.test_type_id.display_name, check.component_id.name or check.workorder_id.name) + check.title = '{} "{}"'.format(check.test_type_id.display_name, check.component_id.name + or check.workorder_id.name) @api.depends('point_id', 'quality_state', 'component_id', 'component_uom_id', 'lot_id', 'qty_done') def _compute_result(self): @@ -266,7 +276,8 @@ class QualityCheck(models.Model): def _get_check_result(self): if self.test_type in ('register_consumed_materials', 'register_byproducts') and self.lot_id: - return '{} - {}, {} {}'.format(self.component_id.name, self.lot_id.name, self.qty_done, self.component_uom_id.name) + return '{} - {}, {} {}'.format(self.component_id.name, self.lot_id.name, self.qty_done, + self.component_uom_id.name) elif self.test_type in ('register_consumed_materials', 'register_byproducts'): return '{}, {} {}'.format(self.component_id.name, self.qty_done, self.component_uom_id.name) else: @@ -281,12 +292,14 @@ class QualityCheck(models.Model): for check in self: if check.test_type in ('register_byproducts', 'register_consumed_materials'): if check.quality_state == 'none': - completed_lines = check.workorder_id.move_line_ids.filtered(lambda l: l.lot_id) if check.component_id.tracking != 'none' else check.workorder_id.move_line_ids + completed_lines = check.workorder_id.move_line_ids.filtered(lambda l: l.lot_id)\ + if check.component_id.tracking != 'none' else check.workorder_id.move_line_ids if check.move_id.additional: qty = check.workorder_id.qty_remaining else: qty = check.workorder_id.qty_producing - check.component_remaining_qty = self._prepare_component_quantity(check.move_id, qty) - sum(completed_lines.mapped('qty_done')) + check.component_remaining_qty = self._prepare_component_quantity(check.move_id, qty) -\ + sum(completed_lines.mapped('qty_done')) check.component_uom_id = check.move_id.product_uom def action_print(self): @@ -369,7 +382,8 @@ class QualityCheck(models.Model): vals_list = [] # apply putaway location_dest_id = self.move_id.location_dest_id._get_putaway_strategy(self.move_id.product_id) - quants = self.env['stock.quant']._gather(self.product_id, self.move_id.location_id, lot_id=self.lot_id, strict=False) + quants = self.env['stock.quant']._gather(self.product_id, self.move_id.location_id, lot_id=self.lot_id, + strict=False) # Search for a sub-locations where the product is available. # Loop on the quants to get the locations. If there is not enough # quantity into stock, we take the move location. Anyway, no @@ -386,7 +400,8 @@ class QualityCheck(models.Model): for quant in quants: vals = shared_vals.copy() quantity = quant.quantity - quant.reserved_quantity - quantity = self.product_id.uom_id._compute_quantity(quantity, self.product_uom_id, rounding_method='HALF-UP') + quantity = self.product_id.uom_id._compute_quantity(quantity, self.product_uom_id, + rounding_method='HALF-UP') rounding = quant.product_uom_id.rounding if (float_compare(quant.quantity, 0, precision_rounding=rounding) <= 0 or float_compare(quantity, 0, precision_rounding=self.product_uom_id.rounding) <= 0): @@ -469,7 +484,8 @@ class QualityCheck(models.Model): def _update_component_quantity(self): if self.component_tracking == 'serial': - self._origin.qty_done = self.component_id.uom_id._compute_quantity(1, self.component_uom_id, rounding_method='HALF-UP') + self._origin.qty_done = self.component_id.uom_id._compute_quantity(1, self.component_uom_id, + rounding_method='HALF-UP') return move = self.move_id # Compute the new quantity for the current component diff --git a/sf_manufacturing/models/res_user.py b/sf_manufacturing/models/res_user.py index b71eaa9f..79b2b42c 100644 --- a/sf_manufacturing/models/res_user.py +++ b/sf_manufacturing/models/res_user.py @@ -5,4 +5,4 @@ from odoo import fields, models class Users(models.Model): _inherit = 'res.users' - workcenter_ids = fields.Many2many("mrp.workcenter", 'users_workcenter') \ No newline at end of file + workcenter_ids = fields.Many2many("mrp.workcenter", 'users_workcenter') diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index a2f5b129..49da3d7a 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -124,7 +124,8 @@ class StockRule(models.Model): moves_values_by_company[procurement.company_id.id].append(move_values) for company_id, moves_values in moves_values_by_company.items(): - # create the move as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example) + # create the move as SUPERUSER because the current user may not have the rights to do it (mto product + # launched by a sale for example) moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(moves_values) # Since action_confirm launch following procurement_group we should activate it. moves._action_confirm() @@ -147,7 +148,8 @@ class StockRule(models.Model): raise ProcurementException(errors) for company_id, productions_values in productions_values_by_company.items(): - # create the MO as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example) + # create the MO as SUPERUSER because the current user may not have the rights to do it (mto product + # launched by a sale for example) '''创建制造订单''' productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( productions_values) @@ -161,7 +163,8 @@ class StockRule(models.Model): productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \ ( - p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm() + p.move_dest_ids.procure_method != 'make_to_order' and not + p.move_raw_ids and not p.workorder_ids)).action_confirm() for production in productions: ''' @@ -187,7 +190,6 @@ class StockRule(models.Model): values={'self': production, 'origin': origin_production}, subtype_id=self.env.ref('mail.mt_note').id) - ''' 创建生产计划 ''' @@ -404,7 +406,8 @@ class ReStockMove(models.Model): 'fixture_clamp_workpiece_diameter_max': item.product_id.fixture_clamp_workpiece_diameter_max, 'fixture_maximum_carrying_weight': item.product_id.fixture_maximum_carrying_weight, 'fixture_maximum_clamping_force': item.product_id.fixture_maximum_clamping_force, - 'fixture_driving_way': '' if not item.product_id.fixture_driving_way else item.product_id.fixture_driving_way, + 'fixture_driving_way': '' if not item.product_id.fixture_driving_way + else item.product_id.fixture_driving_way, 'fixture_apply_machine_tool_type_codes': self.env[ 'product.template']._json_apply_machine_tool_type_item_code(item), 'fixture_through_hole_size': item.product_id.fixture_through_hole_size, @@ -463,12 +466,14 @@ class ReStockMove(models.Model): 'blade_tip_taper': item.product_id.cutting_tool_blade_tip_taper, 'blade_helix_angle': item.product_id.cutting_tool_blade_helix_angle, 'blade_type': item.product_id.cutting_tool_blade_type, - 'coarse_medium_fine': '' if item.product_id.cutting_tool_coarse_medium_fine is False else item.product_id.cutting_tool_coarse_medium_fine, + 'coarse_medium_fine': '' if item.product_id.cutting_tool_coarse_medium_fine is False + else item.product_id.cutting_tool_coarse_medium_fine, 'run_out_accuracy_max': item.product_id.cutting_tool_run_out_accuracy_max, 'run_out_accuracy_min': item.product_id.cutting_tool_run_out_accuracy_min, 'head_diameter': item.product_id.cutting_tool_head_diameter, 'diameter': item.product_id.cutting_tool_diameter, - 'blade_number': '' if item.product_id.cutting_tool_blade_number is False else item.product_id.cutting_tool_blade_number, + 'blade_number': '' if item.product_id.cutting_tool_blade_number is False + else item.product_id.cutting_tool_blade_number, 'front_angle': item.product_id.cutting_tool_front_angle, 'rear_angle': item.product_id.cutting_tool_rear_angle, 'main_included_angle': item.product_id.cutting_tool_main_included_angle, @@ -512,7 +517,8 @@ class ReStockMove(models.Model): 'inner_diameter': item.product_id.cutting_tool_inner_diameter, 'cooling_suit_type_ids': item.product_id.cooling_suit_type_ids, 'er_size_model': item.product_id.cutting_tool_er_size_model, - 'image': '' if not item.product_id.image_1920 else base64.b64encode(item.product_id.image_1920).decode('utf-8'), + 'image': '' if not item.product_id.image_1920 else base64.b64encode(item.product_id.image_1920).decode( + 'utf-8'), } try: if item.product_id.industry_code: diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index a3c4e2a9..1ce0b1d7 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -1,11 +1,24 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sf_cnc_processing,sf_cnc_processing,model_sf_cnc_processing,base.group_user,1,1,1,1 -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_maintenance_equipment_tool,maintenance_equipment_tool,model_maintenance_equipment_tool,base.group_user,1,1,1,1 +access_sf_cnc_processing,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_cnc_processing_manager,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_manager,1,1,1,1 +access_sf_model_type,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_model_type_manager,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_manager,1,1,1,1 +access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_product_model_type_routing_sort_manager,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1 +access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_embryo_model_type_routing_sort_manager,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_manager,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,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_surface_technics_model_type_routing_sort_manager,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1 +access_sf_production_line,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_production_line_manager,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_manager,1,1,1,1 +access_maintenance_equipment_tool,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_user,1,0,0,0 +access_maintenance_equipment_tool_manager,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_manager,1,1,1,1 +access_mrp_production,mrp_production,model_mrp_production,sf_base.group_sf_mrp_user,1,1,1,0 +access_mrp_production_manager,mrp_production,model_mrp_production,sf_base.group_sf_mrp_manager,1,1,1,0 +access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_sf_mrp_user,1,1,1,0 +access_mrp_workorder_manager,mrp_workorder,model_mrp_workorder,sf_base.group_sf_mrp_manager,1,1,1,0 +access_mrp_workcenter,mrp_workcenter,model_mrp_workcenter,sf_base.group_sf_mrp_user,1,1,1,0 +access_mrp_workcenter_manager,mrp_workcenter,model_mrp_workcenter,sf_base.group_sf_mrp_manager,1,1,1,0 diff --git a/sf_manufacturing/views/mrp_views_menus.xml b/sf_manufacturing/views/mrp_views_menus.xml new file mode 100644 index 00000000..1a957427 --- /dev/null +++ b/sf_manufacturing/views/mrp_views_menus.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + diff --git a/sf_sale/models/auto_quatotion_common.py b/sf_sale/models/auto_quatotion_common.py index 09ea3f0f..1b29c6d2 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__) diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index e9f152a8..310bbc7a 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 From 423d5cec8e4c6d24e169f05079182035aa53dff9 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 21 Nov 2023 17:49:58 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BC=98=E5=8C=96sf=5Fmachine=5Fconnect?= =?UTF-8?q?=E7=9A=84manifest=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_machine_connect/__manifest__.py b/sf_machine_connect/__manifest__.py index 6ee1a20a..abc524f1 100644 --- a/sf_machine_connect/__manifest__.py +++ b/sf_machine_connect/__manifest__.py @@ -39,7 +39,7 @@ ], }, - 'external_dependencies': {'python': ['opcua(使用pip install opcua -i https://pypi.tuna.tsinghua.edu.cn/simple)']}, + # 'external_dependencies': {'python': ['opcua(使用pip install opcua -i https://pypi.tuna.tsinghua.edu.cn/simple)']}, 'installable': True, 'application': True, From d6dcb6bf559b2bb3e79b643d1bd21e3b7229d1db Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 22 Nov 2023 09:54:31 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=8E=B0=E6=9C=89?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/src/js/custom_form_status_indicator.js | 5 +++-- jikimo_frontend/static/src/list/custom_width.js | 2 +- sf_bf_connect/models/jd_eclp.py | 2 +- sf_machine_connect/static/src/js/barcode_form.js | 4 ++-- sf_machine_connect/static/src/js/barcode_handler_field.js | 2 +- sf_warehouse/static/src/js/cust_char.js | 2 +- sf_warehouse/static/src/js/custom_many2one.js | 4 ++-- web_widget_model_viewer/static/src/js/3d_viewer.js | 6 +++--- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/jikimo_frontend/static/src/js/custom_form_status_indicator.js b/jikimo_frontend/static/src/js/custom_form_status_indicator.js index fd06fe75..a5f68479 100644 --- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -11,7 +11,7 @@ var Dialog = require('web.Dialog'); patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', { // 你可以重写或者添加一些方法和属性 async _onDiscardChanges() { - var self = this; + // var self = this; Dialog.confirm(this, _t("Are you sure you want to discard changes?"), { title: _t("Discard Changes"), @@ -25,7 +25,8 @@ patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', { // if (window.confirm("Are you sure you want to discard changes?")) { // await this.props.discard(); // } - const result = await this._confirmDiscardChange(); + // const result = await this._confirmDiscardChange(); + await this._confirmDiscardChange(); await this.props.discard(); }, diff --git a/jikimo_frontend/static/src/list/custom_width.js b/jikimo_frontend/static/src/list/custom_width.js index ba35c605..31fd23ca 100644 --- a/jikimo_frontend/static/src/list/custom_width.js +++ b/jikimo_frontend/static/src/list/custom_width.js @@ -10,7 +10,7 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { // The following code manipulates the DOM directly to avoid having to wait for a // render + patch which would occur on the next frame and cause flickering. freezeColumnWidths() { - console.log('ccccccccccccccccccccccccccc') + // console.log('ccccccccccccccccccccccccccc') if (!this.keepColumnWidths) { this.columnWidths = null; } diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py index 6f6b4ab6..a73a9bd0 100644 --- a/sf_bf_connect/models/jd_eclp.py +++ b/sf_bf_connect/models/jd_eclp.py @@ -1,4 +1,4 @@ -# import cpca +import cpca import base64 import logging from datetime import datetime diff --git a/sf_machine_connect/static/src/js/barcode_form.js b/sf_machine_connect/static/src/js/barcode_form.js index d8c898ae..f6190918 100644 --- a/sf_machine_connect/static/src/js/barcode_form.js +++ b/sf_machine_connect/static/src/js/barcode_form.js @@ -1,12 +1,12 @@ odoo.define('my_module.barcode_handler', function (require) { "use strict"; - var core = require('web.core'); + // var core = require('web.core'); var registry = require('web.field_registry'); var session = require('web.session'); var FieldChar = require('web.basic_fields').FieldChar; - var _t = core._t; + // var _t = core._t; var BarcodeHandlerField = FieldChar.extend({ init: function () { diff --git a/sf_machine_connect/static/src/js/barcode_handler_field.js b/sf_machine_connect/static/src/js/barcode_handler_field.js index 6d24d4c6..526f28d7 100644 --- a/sf_machine_connect/static/src/js/barcode_handler_field.js +++ b/sf_machine_connect/static/src/js/barcode_handler_field.js @@ -56,7 +56,7 @@ export class BarcodeHandlerField extends Component { // }); await this.actionService.doAction(response.result); } else { - console.error("Barcode not found or RPC call failed."); + // console.error("Barcode not found or RPC call failed."); } } diff --git a/sf_warehouse/static/src/js/cust_char.js b/sf_warehouse/static/src/js/cust_char.js index 5aa43927..3757bfb8 100644 --- a/sf_warehouse/static/src/js/cust_char.js +++ b/sf_warehouse/static/src/js/cust_char.js @@ -16,7 +16,7 @@ class CustomChar extends CharField { onMounted() { super.onMounted(); - console.log('CustomChar.onMounted1'); + // console.log('CustomChar.onMounted1'); // 当光标聚焦于输入框时,选中输入框内容 this.input.el.addEventListener('focus', function () { this.select(); diff --git a/sf_warehouse/static/src/js/custom_many2one.js b/sf_warehouse/static/src/js/custom_many2one.js index beb4783e..c6a86af5 100644 --- a/sf_warehouse/static/src/js/custom_many2one.js +++ b/sf_warehouse/static/src/js/custom_many2one.js @@ -14,11 +14,11 @@ class CustomMany2One extends Many2OneField { * @returns {Promise} */ setup() { - console.log('CustomMany2One.setup11111111111111'); + // console.log('CustomMany2One.setup11111111111111'); super.setup(); } onMounted() { - console.log('CustomMany2One.onMounted1'); + // console.log('CustomMany2One.onMounted1'); // 当光标聚焦于输入框时,选中输入框内容 this.input.el.addEventListener('focus', function () { this.select(); diff --git a/web_widget_model_viewer/static/src/js/3d_viewer.js b/web_widget_model_viewer/static/src/js/3d_viewer.js index 9d3afd50..18b80052 100644 --- a/web_widget_model_viewer/static/src/js/3d_viewer.js +++ b/web_widget_model_viewer/static/src/js/3d_viewer.js @@ -5,10 +5,10 @@ import {_lt} from "@web/core/l10n/translation"; import {standardFieldProps} from "@web/views/fields/standard_field_props"; import {session} from "@web/session"; -import core from 'web.core'; +// import core from 'web.core'; -var QWeb = core.qweb; +// var QWeb = core.qweb; import {Component} from "@odoo/owl"; @@ -43,7 +43,7 @@ export class StepViewer extends Component { } } else { var oImg = document.getElementsByClassName('test')[0] - console.log(oImg) + // console.log(oImg) } } } From cc58425f50bb61b16ef4202e54dd7fed0e01a383 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 22 Nov 2023 10:29:04 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E8=A7=84=E8=8C=83=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/models/jd_eclp.py | 2 +- sf_manufacturing/static/src/js/kanban_change.js | 12 ++++++------ web_widget_model_viewer/static/src/js/3d_viewer.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py index a73a9bd0..dfcb20f8 100644 --- a/sf_bf_connect/models/jd_eclp.py +++ b/sf_bf_connect/models/jd_eclp.py @@ -1,8 +1,8 @@ -import cpca import base64 import logging from datetime import datetime import requests +import cpca from odoo.exceptions import UserError from odoo.exceptions import ValidationError from odoo import api, fields, models, SUPERUSER_ID, _ diff --git a/sf_manufacturing/static/src/js/kanban_change.js b/sf_manufacturing/static/src/js/kanban_change.js index bc0fd418..72e7abbe 100644 --- a/sf_manufacturing/static/src/js/kanban_change.js +++ b/sf_manufacturing/static/src/js/kanban_change.js @@ -13,9 +13,9 @@ class CustomKanbanController extends KanbanController { async setup() { super.setup(); - console.log('99999999111'); + // console.log('99999999111'); this.workOrders = await this.getAllWorkOrders(); - this.workOrdersNew = this.workOrders; + // this.workOrdersNew = this.workOrders; // console.log('lines222222222', this.workOrders); // // console.log(typeof this.workOrders); @@ -39,14 +39,14 @@ class CustomKanbanController extends KanbanController { const id = button.getAttribute('data-id'); console.log('true_id', id); - const context = {production_line_show: 'shengchanxian1'} + // const context = {production_line_show: 'shengchanxian1'} this.env.services.rpc('/web/dataset/call_kw', { model: 'mrp.workcenter', method: 'search_read', args: [[], ['id']], kwargs: {} }).then((records) => { - console.log(records) + // console.log(records) const ids = records.map(record => record.id); const context = {production_line_show: id}; this.env.services.rpc('/web/dataset/call_kw', { @@ -55,7 +55,7 @@ class CustomKanbanController extends KanbanController { args: [ids, context], kwargs: {} }).then((response) => { - console.log('response', response); + // console.log('response', response); location.reload(); window.onload = function () { button.classList.add('choose') @@ -77,7 +77,7 @@ class CustomKanbanController extends KanbanController { // args: [], // kwargs: {}, // }); - console.log('response', response); + // console.log('response', response); // console.log('response1', response1); // 你可以在这里处理响应,例如将其存储在控制器的状态中 return response; diff --git a/web_widget_model_viewer/static/src/js/3d_viewer.js b/web_widget_model_viewer/static/src/js/3d_viewer.js index 18b80052..3c66b142 100644 --- a/web_widget_model_viewer/static/src/js/3d_viewer.js +++ b/web_widget_model_viewer/static/src/js/3d_viewer.js @@ -42,7 +42,7 @@ export class StepViewer extends Component { // url = "web_widget_model_viewer/static/src/images/not_model.png"; } } else { - var oImg = document.getElementsByClassName('test')[0] + // var oImg = document.getElementsByClassName('test')[0] // console.log(oImg) } } From ae6ec7183e8dc4261c3a3fe0257bd2aa9bbb8771 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 22 Nov 2023 14:22:41 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9sf=5Fmachine=5Fconnect?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=BB=A5=E9=80=82=E9=85=8D=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=9E=84=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/__manifest__.py | 11 +-- sf_machine_connect/models/ftp_client.py | 68 +++++++++---------- sf_machine_connect/models/ftp_operate.py | 1 - sf_machine_connect/models/py2opcua.py | 6 +- .../models/res_config_setting.py | 2 +- sf_machine_connect/views/machine_monitor.xml | 68 ++++++++++--------- 6 files changed, 79 insertions(+), 77 deletions(-) diff --git a/sf_machine_connect/__manifest__.py b/sf_machine_connect/__manifest__.py index abc524f1..db7ae467 100644 --- a/sf_machine_connect/__manifest__.py +++ b/sf_machine_connect/__manifest__.py @@ -22,20 +22,21 @@ 'views/ftp_button.xml', 'views/compensation.xml', + # 只有它被屏蔽了 # 'views/SfWorkOrderBarcodes.xml', 'views/WorkCenterBarcodes.xml', 'views/Stock_picking_Barcodes.xml', - # 'views/machine_monitor.xml', + 'views/machine_monitor.xml', 'views/machine_info_present.xml', 'views/delivery_record.xml', 'views/res_config_settings_views.xml', ], 'assets': { - 'web.assets_backend': [ - # 'sf_machine_connect/static/src/xml/barcode_button.xml', - # 'sf_machine_connect/static/src/js/barcode_button.js', - # 'sf_machine_connect/static/src/css/barcode_button.css', + 'web.assets_backend': [ + # 'sf_machine_connect/static/src/xml/barcode_button.xml', + # 'sf_machine_connect/static/src/js/barcode_button.js', + # 'sf_machine_connect/static/src/css/barcode_button.css', ], }, diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py index d1295217..7ca0ad06 100644 --- a/sf_machine_connect/models/ftp_client.py +++ b/sf_machine_connect/models/ftp_client.py @@ -60,11 +60,11 @@ class FtpButton(models.Model): raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态") # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC" - host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host - port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port - username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num - pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd - remote_path = self.workorder_id.workcenter_id.machine_tool_id.ftp_remote_path + host = self.workorder_id.equipment_id.ftp_host + port = self.workorder_id.equipment_id.ftp_port + username = self.workorder_id.equipment_id.ftp_num + pwd = self.workorder_id.equipment_id.ftp_pwd + remote_path = self.workorder_id.equipment_id.ftp_remote_path print(host, port, username, pwd, remote_path) ftp = ftp_operate.FtpController(host, port, username, pwd) # ftp.delAllfile('C://Users//马广威//Desktop//ftp') @@ -107,8 +107,8 @@ class FtpButton(models.Model): 下发NC代码前自动补偿三元检测偏差值 :return: """ - hongbianliang550 = self.workorder_id.workcenter_id.machine_tool_id.x_compensation_node - hongbianliang551 = self.workorder_id.workcenter_id.machine_tool_id.y_compensation_node + hongbianliang550 = self.workorder_id.equipment_id.x_compensation_node + hongbianliang551 = self.workorder_id.equipment_id.y_compensation_node try: temp_dict = {} temp_dict[hongbianliang550] = self.workorder_id.compensation_value_x @@ -124,9 +124,9 @@ class Machine_ftp(models.Model): """ 数据采集类 """ - _inherit = 'sf.machine_tool' + _inherit = 'maintenance.equipment' - workorder_ids = fields.One2many('mrp.workorder', 'machine_tool_id', string='工单') + # workorder_ids = fields.One2many('mrp.workorder', 'machine_tool_id', string='工单') # 机床配置项目 # ftp相关 @@ -263,7 +263,7 @@ class WorkCenterBarcode(models.Model): compensation_value_y = fields.Float(string='Y轴补偿值') button_compensation_state = fields.Boolean(string='是否已经补偿', readonly=True) button_up_all_state = fields.Boolean(string='是否已经全部下发', readonly=True) - machine_tool_id = fields.Many2one('sf.machine_tool', string='机床') + machine_tool_id = fields.Many2one('sf.machine_tool.type', string='机床') machine_tool_name = fields.Char(string='机床名称', default='未知机床', compute='_run_info', readonly=True) machine_tool_type_id = fields.Char(string='机床型号', default='未知型号', compute='_run_info', readonly=True) machine_tool_status = fields.Boolean(string='在线状态', compute='_run_info', readonly=True) @@ -281,27 +281,27 @@ class WorkCenterBarcode(models.Model): machine_tool_compensation_value_y = fields.Char('y补偿值', compute='_run_info', readonly=True) delivery_records = fields.One2many('delivery.record', 'workorder_id', string="下发记录") - @api.depends('workcenter_id.machine_tool_id.timestamp') + @api.depends('equipment_id.timestamp') def _run_info(self): # self.machine_tool_name = '1号机床' - self.machine_tool_name = self.workcenter_id.machine_tool_id.name - self.machine_tool_type_id = self.workcenter_id.machine_tool_id.type_id.name - self.machine_tool_status = self.workcenter_id.machine_tool_id.status - self.machine_tool_run_status = self.workcenter_id.machine_tool_id.run_status - self.machine_tool_timestamp = self.workcenter_id.machine_tool_id.timestamp - self.machine_tool_time_on = self.workcenter_id.machine_tool_id.time_on - self.machine_tool_time_on_now = self.workcenter_id.machine_tool_id.time_on_now - self.machine_tool_tool_num = self.workcenter_id.machine_tool_id.tool_num - self.machine_tool_program = self.workcenter_id.machine_tool_id.program - self.machine_tool_machine_ip = self.workcenter_id.machine_tool_id.machine_ip - self.machine_tool_cut_status = self.workcenter_id.machine_tool_id.cut_status + self.machine_tool_name = self.equipment_id.name + self.machine_tool_type_id = self.equipment_id.type_id.name + self.machine_tool_status = self.equipment_id.status + self.machine_tool_run_status = self.equipment_id.run_status + self.machine_tool_timestamp = self.equipment_id.timestamp + self.machine_tool_time_on = self.equipment_id.time_on + self.machine_tool_time_on_now = self.equipment_id.time_on_now + self.machine_tool_tool_num = self.equipment_id.tool_num + self.machine_tool_program = self.equipment_id.program + self.machine_tool_machine_ip = self.equipment_id.machine_ip + self.machine_tool_cut_status = self.equipment_id.cut_status self.machine_tool_compensation_value_x = self.compensation_value_x self.machine_tool_compensation_value_y = self.compensation_value_y def compensation(self): - hongbianliang550 = self.workcenter_id.machine_tool_id.x_compensation_node - hongbianliang551 = self.workcenter_id.machine_tool_id.y_compensation_node + hongbianliang550 = self.equipment_id.x_compensation_node + hongbianliang551 = self.equipment_id.y_compensation_node try: temp_dict = {} temp_dict[hongbianliang550] = self.compensation_value_x @@ -339,11 +339,11 @@ class WorkCenterBarcode(models.Model): except Exception: raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态") sequence_collect = [] - host = self.workcenter_id.machine_tool_id.ftp_host - port = self.workcenter_id.machine_tool_id.ftp_port - username = self.workcenter_id.machine_tool_id.ftp_num - pwd = self.workcenter_id.machine_tool_id.ftp_pwd - remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path + host = self.equipment_id.ftp_host + port = self.equipment_id.ftp_port + username = self.equipment_id.ftp_num + pwd = self.equipment_id.ftp_pwd + remote_path = self.equipment_id.ftp_remote_path _logger.info("=====================1666666661111================%s,%s,%s,%s" % (host, port, username, pwd)) ftp = ftp_operate.FtpController(host, port, username, pwd) _logger.info("=====================1777777777111================") @@ -403,11 +403,11 @@ class WorkCenterBarcode(models.Model): except Exception: raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态") sequence_collect = [] - host = self.workcenter_id.machine_tool_id.ftp_host - port = self.workcenter_id.machine_tool_id.ftp_port - username = self.workcenter_id.machine_tool_id.ftp_num - pwd = self.workcenter_id.machine_tool_id.ftp_pwd - remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path + host = self.equipment_id.ftp_host + port = self.equipment_id.ftp_port + username = self.equipment_id.ftp_num + pwd = self.equipment_id.ftp_pwd + remote_path = self.equipment_id.ftp_remote_path _logger.info("=====================1666666661111================%s,%s,%s,%s" % (host, port, username, pwd)) ftp = ftp_operate.FtpController(host, port, username, pwd) _logger.info("=====================1777777777111================") diff --git a/sf_machine_connect/models/ftp_operate.py b/sf_machine_connect/models/ftp_operate.py index a94824f2..457ef6ed 100644 --- a/sf_machine_connect/models/ftp_operate.py +++ b/sf_machine_connect/models/ftp_operate.py @@ -91,7 +91,6 @@ class FtpController: """ self.ftp.close() - def delAllfile(self, ftppath): """ 删除ftp服务器端全部文件 diff --git a/sf_machine_connect/models/py2opcua.py b/sf_machine_connect/models/py2opcua.py index 2b00f394..e7ca2fad 100644 --- a/sf_machine_connect/models/py2opcua.py +++ b/sf_machine_connect/models/py2opcua.py @@ -26,11 +26,11 @@ class Py2opcua: """ # try: self.client.connect() - # print("opcua服务器连接成功,可以写入") - # return self.client + # print("opcua服务器连接成功,可以写入") + # return self.client # except Exception as e: # print("opcua服务器连接失败,请检查" + str(e)) - # temp_dict = temp_dict + # temp_dict = temp_dict temp_list = list(temp_dict.items()) for i in range(len(temp_list)): # 寻找节点上的变量 diff --git a/sf_machine_connect/models/res_config_setting.py b/sf_machine_connect/models/res_config_setting.py index c8257bf8..6d9a6c84 100644 --- a/sf_machine_connect/models/res_config_setting.py +++ b/sf_machine_connect/models/res_config_setting.py @@ -10,7 +10,7 @@ class ResBFMConfigSettings(models.TransientModel): bfm_url = fields.Selection( [("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"), - ("https://bfm.r.jikimo.com", "测试环境(https://bfm.r.jikimo.com)"), + ("https://bfm.t.jikimo.com", "测试环境(https://bfm.t.jikimo.com)"), # ("正式环境", "https://bfm.jikimo.com")], string='bfm环境', store=True) ("https://bfm.jikimo.com", "正式环境(https://bfm.jikimo.com)")], string='bfm环境', store=True) diff --git a/sf_machine_connect/views/machine_monitor.xml b/sf_machine_connect/views/machine_monitor.xml index f07d784a..83b89598 100644 --- a/sf_machine_connect/views/machine_monitor.xml +++ b/sf_machine_connect/views/machine_monitor.xml @@ -2,14 +2,14 @@ sf_base_extension - sf.machine_tool - + maintenance.equipment + - + - + @@ -256,49 +256,51 @@ - + - - sf_cutting_tool_extension - sf.cutting_tool.type - - - - - - - - - - + + + + + + + + + + + - + + + -
+ -
- -
+ -
-
-
-
-
+ + + + +
From 83da8f58e26e018df33a31d9b774fece9a5d8889 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 22 Nov 2023 17:19:25 +0800 Subject: [PATCH 10/14] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E5=88=97=E8=A1=A8=E6=A8=A1=E5=9E=8B=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=A4=A7=E9=87=8F=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=BA=93=E5=AD=98=E6=95=B0=E9=87=8F=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=9F=A5=E7=9C=8B=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=9A=84=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=E8=AE=B0=E5=BD=95=E6=8C=89=E9=94=AE=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E9=87=8D=E6=9E=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E6=A8=A1=E5=9E=8B=EF=BC=88=E5=B7=B2=E5=AE=8C?= =?UTF-8?q?=E6=88=90=EF=BC=89=EF=BC=9B3=E3=80=81=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E6=A8=A1=E5=9E=8Bname?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=B1=95=E7=A4=BA=E5=86=85=E5=AE=B9=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/__init__.py | 1 - sf_tool_management/models/base.py | 339 +++++++------------ sf_tool_management/views/menu_view.xml | 31 +- sf_tool_management/views/tool_base_views.xml | 283 ++++++---------- sf_tool_management/wizard/__init__.py | 2 +- sf_tool_management/wizard/wizard.py | 47 ++- 6 files changed, 270 insertions(+), 433 deletions(-) diff --git a/sf_tool_management/models/__init__.py b/sf_tool_management/models/__init__.py index 67b36bda..3ab6007e 100644 --- a/sf_tool_management/models/__init__.py +++ b/sf_tool_management/models/__init__.py @@ -1,3 +1,2 @@ from . import base from . import tool_material_search - diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 1a7067cb..14f463a0 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -19,9 +19,9 @@ class FunctionalCuttingToolEntity(models.Model): name = fields.Char(related='functional_tool_name_id.name') functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - 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) + sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号') + sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', + group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True) functional_tool_diameter = fields.Integer(string='刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) @@ -30,14 +30,27 @@ class FunctionalCuttingToolEntity(models.Model): tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True) functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True) effective_length = fields.Float(string='有效长(mm)', readonly=True) - tool_room_num = fields.Integer(string='刀具房数量') - line_edge_knife_library_num = fields.Integer(string='线边刀库数量') - machine_knife_library_num = fields.Integer(string='机内刀库数量') + tool_room_num = fields.Integer(string='刀具房数量', readonly=True, ) + line_edge_knife_library_num = fields.Integer(string='线边刀库数量', readonly=True) + machine_knife_library_num = fields.Integer(string='机内刀库数量', readonly=True) max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) alarm_value = fields.Integer(string='报警值(min)', readonly=True) used_value = fields.Integer(string='已使用值(min)', readonly=True) functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], string='状态', store=True, default='正常') + current_location_id = fields.Many2one('stock.location', string='当前位置', readonly=True) + image = fields.Binary('图片', readonly=True) + + @api.depends('current_location_id') + def _compute_location_num(self): + """ + 计算库存位置数量 + """ + for obj in self: + if obj.current_location_id.name in ('组装后', '刀具房'): + obj.tool_room_num = 1 + obj.line_edge_knife_library_num = 0 + obj.machine_knife_library_num = 0 @api.model def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order): @@ -47,64 +60,44 @@ class FunctionalCuttingToolEntity(models.Model): # 整体式刀具型号 cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, domain=[('cutting_tool_material_id', '=', '整体式刀具')]) - # 刀片型号 cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, domain=[('cutting_tool_material_id', '=', '刀片')]) - # 刀杆型号 cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, domain=[('cutting_tool_material_id', '=', '刀杆')]) - # 刀盘型号 cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, domain=[('cutting_tool_material_id', '=', '刀盘')]) - # 刀柄型号 cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, domain=[('cutting_tool_material_id', '=', '刀柄')]) - # 夹头型号 cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, domain=[('cutting_tool_material_id', '=', '夹头')]) - 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('装刀长(mm)') - blade_number = fields.Integer('刃数') - integral_blade_length = fields.Float('整体刃长(mm)') - effective_blade_length = fields.Float('有效刃长(mm)') - max_life = fields.Float('最大寿命值') - is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀') - applicable_range = fields.Char('适用范围') - image = fields.Binary('图片') + whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True) + L_D_number = fields.Float(string='L/D值(mm)', readonly=True) + hiding_length = fields.Float(string='避空长(mm)', readonly=True) + cut_time = fields.Integer(string='已切削时间(min)', readonly=True) + cut_length = fields.Float(string='已切削长度(mm)', readonly=True) + cut_number = fields.Integer(string='已切削次数', readonly=True) - suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image', - 'rel_machining_product_template_tool_entity', '适合加工方式', - domain=[('type', '=', '加工能力')], - related='cutting_tool_integral_model_id.suitable_machining_method_ids') - - 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_id') - - handle_type_ids = fields.Many2many('maintenance.equipment.image', - 'rel_handle_product_template_tool_entity', '柄部类型', - domain=[('type', '=', '柄部类型')], - related='cutting_tool_integral_model_id.handle_type_ids') - - cutting_direction_ids = fields.Many2many('maintenance.equipment.image', - 'rel_cutting_product_template_tool_entity', '走刀方向', - domain=[('type', '=', '走刀方向')], - related='cutting_tool_integral_model_id.cutting_direction_ids') - - suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', - 'rel_coolant_product_template_tool_entity', '适合冷却液', - domain=[('type', '=', '冷却液')], - related='cutting_tool_integral_model_id.suitable_coolant_ids') + suitable_machining_method_ids = fields.Many2many( + 'maintenance.equipment.image', 'rel_machining_product_template_tool_entity', '适合加工方式', + domain=[('type', '=', '加工能力')], related='cutting_tool_integral_model_id.suitable_machining_method_ids') + 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_id') + handle_type_ids = fields.Many2many( + 'maintenance.equipment.image', 'rel_handle_product_template_tool_entity', '柄部类型', + domain=[('type', '=', '柄部类型')], related='cutting_tool_integral_model_id.handle_type_ids') + cutting_direction_ids = fields.Many2many( + 'maintenance.equipment.image', 'rel_cutting_product_template_tool_entity', '走刀方向', + domain=[('type', '=', '走刀方向')], related='cutting_tool_integral_model_id.cutting_direction_ids') + suitable_coolant_ids = fields.Many2many( + 'maintenance.equipment.image', 'rel_coolant_product_template_tool_entity', '适合冷却液', + domain=[('type', '=', '冷却液')], related='cutting_tool_integral_model_id.suitable_coolant_ids') def _get_functional_tool_model_ids(self, functional_tool_model_code): functional_tool_model_ids = [] @@ -114,112 +107,48 @@ class FunctionalCuttingToolEntity(models.Model): return [(6, 0, functional_tool_model_ids)] def open_functional_tool_warning(self): - pass + action = self.env.ref('sf_tool_management.action_sf_functional_tool_warning') + result = action.read()[0] + result['domain'] = [('functional_tool_name_id', '=', self.functional_tool_name_id.id)] + return result class FunctionalToolWarning(models.Model): _name = 'sf.functional.tool.warning' _description = '功能刀具预警' - functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) - functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True) - - # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True, - related='functional_cutting_tool_id.barcode_id') - name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name') - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True, - related='functional_cutting_tool_id.functional_tool_name_id') - mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - related='functional_cutting_tool_id.mrs_cutting_tool_type_id') - - # 整体式刀具型号 - cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '整体式刀具')], - related='functional_cutting_tool_id.cutting_tool_integral_model_id') - - # 刀片型号 - cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀片')], - related='functional_cutting_tool_id.cutting_tool_blade_model_id') - - # 刀杆型号 - cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀杆')], - related='functional_cutting_tool_id.cutting_tool_cutterbar_model_id') - - # 刀盘型号 - cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀盘')], - related='functional_cutting_tool_id.cutting_tool_cutterpad_model_id') - - # 刀柄型号 - cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀柄')], - related='functional_cutting_tool_id.cutting_tool_cutterhandle_model_id') - - # 夹头型号 - cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '夹头')], - related='functional_cutting_tool_id.cutting_tool_cutterhead_model_id') - - diameter = fields.Float('直径(mm)', readonly=True, related='functional_cutting_tool_id.diameter') - tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') - machining_accuracy = fields.Float('加工精度(mm)', readonly=True, - related='functional_cutting_tool_id.machining_accuracy') - - # tool_length = fields.Float('装刀长', readonly=True, related='functional_cutting_tool_id.tool_length') - - tool_length = fields.Float('装刀长(mm)', readonly=True, related='functional_cutting_tool_id.tool_length') - blade_number = fields.Integer('刃数', readonly=True, related='functional_cutting_tool_id.blade_number') - integral_blade_length = fields.Float('整体刃长(mm)', readonly=True, - related='functional_cutting_tool_id.integral_blade_length') - effective_blade_length = fields.Float('有效刃长(mm)', readonly=True, - related='functional_cutting_tool_id.effective_blade_length') - max_life = fields.Float('最大寿命值', readonly=True, related='functional_cutting_tool_id.max_life') - is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀', readonly=True, - compute='_compute_functional_cutting_tool_id') - applicable_range = fields.Char('适用范围', readonly=True, related='functional_cutting_tool_id.applicable_range') - - image = fields.Binary('图片', readonly=True, related='functional_cutting_tool_id.image') - install_tool_time = fields.Datetime("装刀时间", readonly=True, - related='functional_tool_assembly_id.tool_loading_time') - - @api.depends('functional_cutting_tool_id') - def _compute_functional_cutting_tool_id(self): - if self.functional_cutting_tool_id: - self.tool_grade = self.functional_cutting_tool_id.tool_grade - self.is_standard = self.functional_cutting_tool_id.is_standard - - # 功能刀具预警 特有字段 - outbound_time = fields.Datetime('出库时间', readonly=True) - on_board_time = fields.Datetime('上机时间', readonly=False) - machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=True, - group_expand='_read_group_machine_table_name_ids') + name = fields.Char('名称', invisible=True, readonly=True, related='functional_tool_name_id.name') + # 机床信息 + production_line_id = fields.Many2one('sf.production.line', string='生产线', + group_expand='_read_group_machine_table_name_ids') + maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床') + machine_tool_code = fields.Char(string='机台号') + machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型') + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', + domain="[('equipment_id', '=', maintenance_equipment_id)]") + # 功能刀具信息 + functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', related='functional_tool_name_id.barcode_id') + mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') + diameter = fields.Integer(string='刀具直径(mm)') + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') + # 其他信息 + install_tool_time = fields.Datetime("刀具组装时间") + on_board_time = fields.Datetime('上机装刀时间') + max_lifetime_value = fields.Integer(string='最大寿命值(min)') + alarm_value = fields.Integer(string='报警值(min)') + used_value = fields.Integer(string='已使用值(min)') + functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], string='状态') + alarm_time = fields.Char('报警时间') + dispose_user = fields.Char('处理人') + dispose_time = fields.Char('处理时间') + dispose_func = fields.Char('处理方法/措施', readonly=False) @api.model def _read_group_machine_table_name_ids(self, categories, domain, order): machine_table_name_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) return categories.browse(machine_table_name_ids) - machine_tool_code = fields.Char('机台号', readonly=True, related='functional_tool_assembly_id.machine_tool_code') - cutting_tool_code = fields.Char('刀位号', readonly=True) - # idle_time = fields.Char('闲置时长', readonly=False) - idle_time = fields.Char('闲置时长(h)', readonly=False) - alarm_value = fields.Char('报警值', readonly=False) - used_value = fields.Char('已使用值', readonly=False) - alarm_type = fields.Char('报警类型', readonly=False) - dispose_user = fields.Char('处理人', readonly=False) - alarm_time = fields.Char('报警时间', readonly=False) - dispose_time = fields.Char('处理时间', readonly=False) - dispose_func = fields.Char('处理方法/措施', readonly=False) - remark = fields.Char('备注', readonly=False) - - @api.onchange('functional_cutting_tool_id') - def onchange_functional_cutting_tool_id(self): - print(self.functional_cutting_tool_id.name) - class RealTimeDistributionOfFunctionalTools(models.Model): _name = 'sf.real.time.distribution.of.functional.tools' @@ -243,60 +172,61 @@ class RealTimeDistributionOfFunctionalTools(models.Model): record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True, - related='functional_cutting_tool_id.barcode_id') - name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name') - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True, - related='functional_cutting_tool_id.functional_tool_name_id') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) + name = fields.Char('名称', invisible=True, readonly=True) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) # mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, # related='functional_cutting_tool_id.mrs_cutting_tool_type_id') # 整体式刀具型号 - cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '整体式刀具')], - related='functional_cutting_tool_id.cutting_tool_integral_model_id') + cutting_tool_integral_model_id = fields.Many2one( + 'product.product', string='整体式刀具型号', readonly=True, + domain=[('cutting_tool_material_id', '=', '整体式刀具')], + related='functional_cutting_tool_id.cutting_tool_integral_model_id') # 刀片型号 - cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀片')], - related='functional_cutting_tool_id.cutting_tool_blade_model_id') + cutting_tool_blade_model_id = fields.Many2one( + 'product.product', string='刀片型号', readonly=True, + domain=[('cutting_tool_material_id', '=', '刀片')], + related='functional_cutting_tool_id.cutting_tool_blade_model_id') # 刀杆型号 - cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀杆')], - related='functional_cutting_tool_id.cutting_tool_cutterbar_model_id') + cutting_tool_cutterbar_model_id = fields.Many2one( + 'product.product', string='刀杆型号', readonly=True, + domain=[('cutting_tool_material_id', '=', '刀杆')], + related='functional_cutting_tool_id.cutting_tool_cutterbar_model_id') # 刀盘型号 - cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀盘')], - related='functional_cutting_tool_id.cutting_tool_cutterpad_model_id') + cutting_tool_cutterpad_model_id = fields.Many2one( + 'product.product', string='刀盘型号', readonly=True, + domain=[('cutting_tool_material_id', '=', '刀盘')], + related='functional_cutting_tool_id.cutting_tool_cutterpad_model_id') # 刀柄型号 - cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀柄')], - related='functional_cutting_tool_id.cutting_tool_cutterhandle_model_id') + cutting_tool_cutterhandle_model_id = fields.Many2one( + 'product.product', string='刀柄型号', readonly=True, + domain=[('cutting_tool_material_id', '=', '刀柄')], + related='functional_cutting_tool_id.cutting_tool_cutterhandle_model_id') # 夹头型号 - cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '夹头')], - related='functional_cutting_tool_id.cutting_tool_cutterhead_model_id') + cutting_tool_cutterhead_model_id = fields.Many2one( + 'product.product', string='夹头型号', readonly=True, + domain=[('cutting_tool_material_id', '=', '夹头')], + related='functional_cutting_tool_id.cutting_tool_cutterhead_model_id') - diameter = fields.Float('直径(mm)', readonly=True, related='functional_cutting_tool_id.diameter') + diameter = fields.Float('直径(mm)', readonly=True) tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') - machining_accuracy = fields.Float('加工精度(mm)', readonly=True, - related='functional_cutting_tool_id.machining_accuracy') - tool_length = fields.Float('装刀长(mm)', readonly=True, related='functional_cutting_tool_id.tool_length') - blade_number = fields.Integer('刃数', readonly=True, related='functional_cutting_tool_id.blade_number') - integral_blade_length = fields.Float('整体刃长(mm)', readonly=True, - related='functional_cutting_tool_id.integral_blade_length') - effective_blade_length = fields.Float('有效刃长(mm)', readonly=True, - related='functional_cutting_tool_id.effective_blade_length') - max_life = fields.Float('最大寿命值', readonly=True, related='functional_cutting_tool_id.max_life') + string='刀具等级', readonly=True) + machining_accuracy = fields.Float('加工精度(mm)', readonly=True) + tool_length = fields.Float('装刀长(mm)', readonly=True) + blade_number = fields.Integer('刃数', readonly=True) + integral_blade_length = fields.Float('整体刃长(mm)', readonly=True) + effective_blade_length = fields.Float('有效刃长(mm)', readonly=True) + max_life = fields.Float('最大寿命值', readonly=True) is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀', readonly=True, compute='_compute_functional_cutting_tool_id') - applicable_range = fields.Char('适用范围', readonly=True, related='functional_cutting_tool_id.applicable_range') - image = fields.Binary('图片', readonly=True, related='functional_cutting_tool_id.image') + applicable_range = fields.Char('适用范围', readonly=True) + image = fields.Binary('图片', readonly=True) @api.depends('functional_cutting_tool_id') def _compute_functional_cutting_tool_id(self): @@ -326,7 +256,8 @@ class RealTimeDistributionOfFunctionalTools(models.Model): def _compute_return_total(self): for record in self: if record: - self.return_total = record.return_reuse_num_re + record.return_reuse_num_co + record.return_processing_num + self.return_total = (record.return_reuse_num_re + record.return_reuse_num_co + + record.return_processing_num) @api.depends('tool_stock_total', 'return_total') def _compute_total(self): @@ -357,58 +288,47 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model): record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True, - related='functional_cutting_tool_id.barcode_id') - name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name') - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True, - related='functional_cutting_tool_id.functional_tool_name_id') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) + name = fields.Char('名称', invisible=True, readonly=True) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) # 整体式刀具型号 cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '整体式刀具')], - related='functional_cutting_tool_id.cutting_tool_integral_model_id') + domain=[('cutting_tool_material_id', '=', '整体式刀具')]) # 刀片型号 cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀片')], - related='functional_cutting_tool_id.cutting_tool_blade_model_id') + domain=[('cutting_tool_material_id', '=', '刀片')]) # 刀杆型号 cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀杆')], - related='functional_cutting_tool_id.cutting_tool_cutterbar_model_id') + domain=[('cutting_tool_material_id', '=', '刀杆')]) # 刀盘型号 cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀盘')], - related='functional_cutting_tool_id.cutting_tool_cutterpad_model_id') + domain=[('cutting_tool_material_id', '=', '刀盘')]) # 刀柄型号 cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀柄')], - related='functional_cutting_tool_id.cutting_tool_cutterhandle_model_id') + domain=[('cutting_tool_material_id', '=', '刀柄')]) # 夹头型号 cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '夹头')], - related='functional_cutting_tool_id.cutting_tool_cutterhead_model_id') + domain=[('cutting_tool_material_id', '=', '夹头')]) - diameter = fields.Float('直径(mm)', readonly=True, related='functional_cutting_tool_id.diameter') + diameter = fields.Float('直径(mm)', readonly=True) tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') - machining_accuracy = fields.Float('加工精度(mm)', readonly=True, - related='functional_cutting_tool_id.machining_accuracy') - tool_length = fields.Float('装刀长(mm)', readonly=True, related='functional_cutting_tool_id.tool_length') - blade_number = fields.Integer('刃数', readonly=True, related='functional_cutting_tool_id.blade_number') - integral_blade_length = fields.Float('整体刃长(mm)', readonly=True, - related='functional_cutting_tool_id.integral_blade_length') - effective_blade_length = fields.Float('有效刃长(mm)', readonly=True, - related='functional_cutting_tool_id.effective_blade_length') - max_life = fields.Float('最大寿命值', readonly=True, related='functional_cutting_tool_id.max_life') + machining_accuracy = fields.Float('加工精度(mm)', readonly=True) + tool_length = fields.Float('装刀长(mm)', readonly=True) + blade_number = fields.Integer('刃数', readonly=True) + integral_blade_length = fields.Float('整体刃长(mm)', readonly=True) + effective_blade_length = fields.Float('有效刃长(mm)', readonly=True) + max_life = fields.Float('最大寿命值', readonly=True) is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀', readonly=True, compute='_compute_functional_cutting_tool_id') - applicable_range = fields.Char('适用范围', readonly=True, related='functional_cutting_tool_id.applicable_range') - image = fields.Binary('图片', readonly=True, related='functional_cutting_tool_id.image') + applicable_range = fields.Char('适用范围', readonly=True) + image = fields.Binary('图片', readonly=True) @api.depends('functional_cutting_tool_id') def _compute_functional_cutting_tool_id(self): @@ -469,8 +389,7 @@ class MachineTableToolChangingApply(models.Model): compute='_compute_machine_table_type_id') machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=False, - required=True, - domain="[('equipment_id', '=', name)]") + required=True, domain="[('equipment_id', '=', maintenance_equipment_id)]") barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', domain=[('product_id.name', '=', '功能刀具')]) functional_tool_name = fields.Char(string='功能刀具名称') @@ -712,7 +631,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('functional_tool_name') def _compute_name(self): for obj in self: - obj.name = obj.functional_tool_name + obj.name = obj.after_assembly_functional_tool_name name = fields.Char(string='名称', readonly=True, compute='_compute_name') assembly_order_code = fields.Char(string='编码', readonly=True) diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index 5b1ed7e9..efa4feee 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -13,7 +13,7 @@ name="功能刀具列表" sequence="4" action="sf_function_tool_entry_list_view_act" - /> + /> + /> + /> - - - - - - - + + /> + /> + /> - + /> - \ No newline at end of file + diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index b07fe225..1cac4820 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -9,14 +9,24 @@ - - - - - - - + + + + + + + + + + + + + + + + +
@@ -26,6 +36,9 @@ sf.functional.cutting.tool.entity
+
+ +
@@ -50,7 +63,7 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - + + + + + + + + @@ -167,15 +155,28 @@ - - - - - - - + + + + + + + + + + + + + + + + + + - + + + @@ -194,148 +195,54 @@ sf.functional.tool.warning.tree sf.functional.tool.warning - + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - sf.functional.tool.warning.form - sf.functional.tool.warning - - - -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- sf.functional.tool.warning.search sf.functional.tool.warning + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - + + @@ -345,7 +252,7 @@ 功能刀具预警 ir.actions.act_window sf.functional.tool.warning - tree,form,search + tree,search @@ -1114,6 +1021,7 @@ name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d" type="action" context="{'default_name':name, + 'default_assembly_order_code':assembly_order_code, 'default_production_line_name_id':production_line_name_id, 'default_machine_tool_name_id':machine_tool_name_id, 'default_cutter_spacing_code_id':cutter_spacing_code_id, @@ -1150,6 +1058,7 @@ name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d" type="action" context="{'default_name':name, + 'default_assembly_order_code':assembly_order_code, 'default_production_line_name_id':production_line_name_id, 'default_machine_tool_name_id':machine_tool_name_id, 'default_cutter_spacing_code_id':cutter_spacing_code_id, diff --git a/sf_tool_management/wizard/__init__.py b/sf_tool_management/wizard/__init__.py index 20a7f5c4..40272379 100644 --- a/sf_tool_management/wizard/__init__.py +++ b/sf_tool_management/wizard/__init__.py @@ -1 +1 @@ -from . import wizard \ No newline at end of file +from . import wizard diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 3c17bf47..990addf1 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -154,6 +154,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): _inherit = ["barcodes.barcode_events_mixin"] _description = '功能刀具组装单' + assembly_order_code = fields.Char(string='编码', readonly=True) functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True) functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, @@ -320,7 +321,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): cut_number = fields.Integer(string='已切削次数') after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True) - after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='组装后粗/中/精') + after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], + string='组装后粗/中/精') after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)') after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)') after_assembly_used_value = fields.Integer(string='组装后已使用值(min)') @@ -348,6 +350,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 封装功能刀具数据 desc_1 = self.get_desc_1(stock_lot) functional_tool_assembly = self.env['sf.functional.tool.assembly'].search([ + ('assembly_order_code', '=', self.assembly_order_code), ('machine_tool_name_id', '=', self.machine_tool_name_id.id), ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id), ('assemble_status', '=', '0'), @@ -355,9 +358,9 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 创建功能刀具列表记录 # 封装功能刀具数据 - # desc_2 = self.get_desc_2(stock_lot) - # # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 - # record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) + desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly) + # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 + record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) # self.env['sf.functional.tool.warning'].create({ # 'functional_cutting_tool_id': record_1.id, # 'functional_tool_assembly_id': functional_tool_assembly.id, @@ -512,26 +515,34 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'tool_loading_time': fields.Datetime.now() } - def get_desc_2(self, stock_lot): + def get_desc_2(self, stock_lot, functional_tool_assembly_id): return { 'barcode_id': stock_lot.id, - 'functional_tool_name_id': self.functional_tool_name_id.id, - 'mrs_cutting_tool_type_id': self.functional_tool_type_id.id, + 'functional_tool_name_id': functional_tool_assembly_id.id, + 'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id, 'cutting_tool_integral_model_id': self.integral_code_id.product_id.id, 'cutting_tool_blade_model_id': self.blade_code_id.product_id.id, 'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id, 'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id, 'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id, 'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id, - 'diameter': self.functional_tool_diameter, - 'tool_grade': None, - 'machining_accuracy': None, - 'tool_length': self.tool_loading_length, - 'blade_number': None, - 'integral_blade_length': None, - 'effective_blade_length': self.effective_length, - 'max_life': None, - 'is_standard': self.whether_standard_tool, - 'applicable_range': None, - 'image': None, + + 'functional_tool_diameter': self.after_assembly_functional_tool_diameter, + 'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle, + 'coarse_middle_thin': self.after_assembly_coarse_middle_thin, + 'new_former': self.after_assembly_new_former, + 'tool_loading_length': self.after_assembly_tool_loading_length, + 'functional_tool_length': self.after_assembly_functional_tool_length, + 'effective_length': self.after_assembly_effective_length, + + 'max_lifetime_value': self.after_assembly_max_lifetime_value, + 'alarm_value': self.after_assembly_alarm_value, + 'used_value': self.after_assembly_used_value, + 'whether_standard_knife': self.after_assembly_whether_standard_knife, + 'L_D_number': self.L_D_number, + 'hiding_length': self.hiding_length, + 'cut_time': self.cut_time, + 'cut_length': self.cut_length, + 'cut_number': self.cut_number, + 'current_location_id': stock_lot.quant_ids.location_id.ids[-1], } From b4b5207aea7c680f4a303f3fd6c1c61f48662f45 Mon Sep 17 00:00:00 2001 From: "qihao.gong@jikimo.com" Date: Wed, 22 Nov 2023 17:36:50 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=B6=E9=80=A0=E6=A8=A1=E5=9D=97=E6=9D=83=E9=99=90=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E5=A4=87=E6=9C=BA=E5=BA=8A=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E7=9A=84=E5=B8=83=E5=B1=80=E4=BB=A5=E5=8F=8A=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/security/group_security.xml | 18 ++++++++++------- sf_maintenance/models/sf_maintenance.py | 20 ++++++++++++++++--- sf_maintenance/views/maintenance_views.xml | 6 ++++-- sf_manufacturing/security/ir.model.access.csv | 8 +++++--- .../views/production_line_view.xml | 2 +- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/sf_base/security/group_security.xml b/sf_base/security/group_security.xml index 770fe378..60daf15e 100644 --- a/sf_base/security/group_security.xml +++ b/sf_base/security/group_security.xml @@ -4,12 +4,16 @@ 制造普通用户 - - 制造管理用户 - - - - + + + + + + + + + + 机床操作岗 @@ -28,7 +32,7 @@ 生产总监 - + diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index 2e546366..a46f7f69 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -63,7 +63,7 @@ class SfMaintenanceEquipment(models.Model): else: record.equipment_maintenance_standards_ids = False - MTcode = fields.Char("编码", default=get_no) + MTcode = fields.Char("机台编码", default=get_no) created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')] , compute='_compute_category_id') @@ -74,8 +74,8 @@ class SfMaintenanceEquipment(models.Model): if record: record.equipment_type = record.category_id.equipment_type - code = fields.Char('机台号') - name = fields.Char('名称') + code = fields.Char('行业编码') + name = fields.Char('机台号') knife_type = fields.Selection( [("BT40", "BT40"), ("BT30", "BT30"), ("BT50", "BT50")], default="", string="刀把类型") @@ -154,6 +154,20 @@ class SfMaintenanceEquipment(models.Model): result.append((parameter.id, name)) return result + @api.model + def create(self, vals): + # 在创建设备之前执行一些自定义逻辑 + + vals.name = vals.MTcode + '#' + vals.type_id.name + + + equipment = super(SfMaintenanceEquipment, self).create(vals) + + # 在创建设备之后执行一些自定义逻辑 + # ... + + return equipment + # @api.constrains('rotate_speed') # def _check_rotate_speed(self): # if self.rotate_speed <= 0: diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 435e291c..ff0b6e73 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -52,11 +52,13 @@
+ + + - - + maintenance.equipment - + From baaeac10eb5702b8304ef7e6a5142eca43deb4c1 Mon Sep 17 00:00:00 2001 From: "qihao.gong@jikimo.com" Date: Thu, 23 Nov 2023 16:33:09 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=90=8D=E7=A7=B0=E8=A7=84=E5=88=99=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=B6=E9=80=A0=E6=A8=A1=E5=9D=97=E6=9D=83?= =?UTF-8?q?=E9=99=90=E7=BB=84=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/security/group_security.xml | 3 ++- sf_base/security/ir.model.access.csv | 2 ++ sf_maintenance/models/sf_maintenance.py | 4 +--- sf_manufacturing/models/product_template.py | 4 ++-- sf_sale/models/auto_quatotion_common.py | 2 +- sf_sale/models/quick_easy_order.py | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sf_base/security/group_security.xml b/sf_base/security/group_security.xml index 60daf15e..d727278a 100644 --- a/sf_base/security/group_security.xml +++ b/sf_base/security/group_security.xml @@ -3,11 +3,12 @@ 制造普通用户 + - + diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 37daa2b3..1a550d41 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -40,3 +40,5 @@ access_maintenance_equipment_image,maintenance_equipment_image,model_maintenance + + diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index a46f7f69..d4aa6ba4 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -158,10 +158,8 @@ class SfMaintenanceEquipment(models.Model): def create(self, vals): # 在创建设备之前执行一些自定义逻辑 - vals.name = vals.MTcode + '#' + vals.type_id.name - - equipment = super(SfMaintenanceEquipment, self).create(vals) + equipment.name = equipment.MTcode + '#' + equipment.category_id.name # 在创建设备之后执行一些自定义逻辑 # ... diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index ea0841ad..73d3d4aa 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -3,8 +3,8 @@ 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 +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file import logging import base64 import hashlib diff --git a/sf_sale/models/auto_quatotion_common.py b/sf_sale/models/auto_quatotion_common.py index 1b29c6d2..09ea3f0f 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__) diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 310bbc7a..e9f152a8 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 From 97d760cd5625b5025e301f6e2db278a12483055b Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 23 Nov 2023 17:15:34 +0800 Subject: [PATCH 13/14] =?UTF-8?q?1=E3=80=81=E5=9F=BA=E4=BA=8E=E5=8E=9F?= =?UTF-8?q?=E7=94=9F=E7=9A=84=E7=A7=BB=E5=8A=A8=E5=8E=86=E5=8F=B2=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E8=AE=B0=E5=BD=95=E6=A8=A1=E5=9E=8B=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E8=AE=B0=E5=BD=95=E6=8C=89=E9=92=AE=EF=BC=9B3?= =?UTF-8?q?=E3=80=81=E5=88=A0=E9=99=A4=E6=97=A7=E7=9A=84=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=92=8C=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E4=BA=BA=E6=A8=A1=E5=9E=8B=EF=BC=9B4=E3=80=81?= =?UTF-8?q?=E6=9C=BA=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=AD=97=E6=AE=B5=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=8D=95?= =?UTF-8?q?=EF=BC=9B5=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=8D=95=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E5=8A=9F=E8=83=BD=E7=9A=84=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/model_type.py | 9 +- .../models/production_line_base.py | 7 +- sf_plan_management/__init__.py | 2 +- sf_plan_management/models/__init__.py | 2 +- sf_plan_management/models/base.py | 4 - sf_tool_management/models/base.py | 169 ++++--------- .../security/ir.model.access.csv | 2 - sf_tool_management/views/menu_view.xml | 6 +- sf_tool_management/views/tool_base_views.xml | 231 ++++-------------- sf_tool_management/wizard/wizard.py | 35 ++- 10 files changed, 110 insertions(+), 357 deletions(-) diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index cfa5bea8..48707939 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -1,7 +1,4 @@ -from odoo import fields, models,api - - - +from odoo import fields, models, api class ModelType(models.Model): @@ -42,8 +39,6 @@ class ProductModelTypeRoutingSort(models.Model): # if record: # record.routing_type = record.route_workcenter_id.routing_type - - routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') @@ -77,7 +72,6 @@ class EmbryoModelTypeRoutingSort(models.Model): # if record: # record.routing_type = record.route_workcenter_id.routing_type - routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') @@ -111,7 +105,6 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model): # if record: # record.routing_type = record.route_workcenter_id.routing_type - routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') diff --git a/sf_manufacturing/models/production_line_base.py b/sf_manufacturing/models/production_line_base.py index 2cb704f0..f0ee5338 100644 --- a/sf_manufacturing/models/production_line_base.py +++ b/sf_manufacturing/models/production_line_base.py @@ -1,4 +1,4 @@ -from odoo import models,fields +from odoo import models, fields class ProductionLine(models.Model): @@ -26,8 +26,3 @@ class ProductionLine(models.Model): name = fields.Char('生产线', size=20, required=True) code = fields.Char('编码', default=_get_code, readonly=True) remark = fields.Char('备注') - - - - - diff --git a/sf_plan_management/__init__.py b/sf_plan_management/__init__.py index 9a7e03ed..0650744f 100644 --- a/sf_plan_management/__init__.py +++ b/sf_plan_management/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/sf_plan_management/models/__init__.py b/sf_plan_management/models/__init__.py index 9a2c9000..c58a46c7 100644 --- a/sf_plan_management/models/__init__.py +++ b/sf_plan_management/models/__init__.py @@ -1,2 +1,2 @@ from . import calendar_base -from . import base \ No newline at end of file +from . import base diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py index dffc0ef6..d1eff04a 100644 --- a/sf_plan_management/models/base.py +++ b/sf_plan_management/models/base.py @@ -44,7 +44,3 @@ class ProcedureEquipmentResourceSetting(models.Model): record.working_shift_id = record.working_calendar_id.working_shift_ids else: record.working_shift_id = None - - - - diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 14f463a0..7402632f 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -112,6 +112,12 @@ class FunctionalCuttingToolEntity(models.Model): result['domain'] = [('functional_tool_name_id', '=', self.functional_tool_name_id.id)] return result + def open_stock_move_line(self): + action = self.env.ref('sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_act') + result = action.read()[0] + result['domain'] = [('lot_id', '=', self.barcode_id.id), ('qty_done', '>', 0)] + return result + class FunctionalToolWarning(models.Model): _name = 'sf.functional.tool.warning' @@ -150,9 +156,27 @@ class FunctionalToolWarning(models.Model): return categories.browse(machine_table_name_ids) +class StockMoveLine(models.Model): + _inherit = 'stock.move.line' + _description = '功能刀具出入库记录' + + functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, + group_expand='_read_group_functional_tool_type_id', + related='functional_tool_name_id.functional_tool_type_id') + diameter = fields.Integer(string='刀具直径(mm)', related='functional_tool_name_id.functional_tool_diameter') + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle') + install_tool_time = fields.Datetime("刀具组装时间") + + @api.model + def _read_group_functional_tool_type_id(self, categories, domain, order): + names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) + return categories.browse(names) + + class RealTimeDistributionOfFunctionalTools(models.Model): _name = 'sf.real.time.distribution.of.functional.tools' - _description = '功能刀具实时分布' + _description = '功能刀具安全库存' functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, @@ -171,12 +195,9 @@ class RealTimeDistributionOfFunctionalTools(models.Model): if record: record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id - # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) name = fields.Char('名称', invisible=True, readonly=True) functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) - # mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - # related='functional_cutting_tool_id.mrs_cutting_tool_type_id') # 整体式刀具型号 cutting_tool_integral_model_id = fields.Many2one( @@ -266,115 +287,6 @@ class RealTimeDistributionOfFunctionalTools(models.Model): self.total = record.tool_stock_total + record.return_total -class InboundAndOutboundRecordsOfFunctionalTools(models.Model): - _name = 'sf.inbound.and.outbound.records.of.functional.tools' - _description = '功能刀具出入库记录' - - functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) - mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - group_expand='_read_mrs_cutting_tool_type_ids', - store=True, - compute='_compute_functional_cutting_tool_ids') - - @api.model - def _read_mrs_cutting_tool_type_ids(self, categories, domain, order): - mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) - return categories.browse(mrs_cutting_tool_type_ids) - - @api.depends('functional_cutting_tool_id') - def _compute_functional_cutting_tool_ids(self): - for record in self: - if record: - record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id - - # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - name = fields.Char('名称', invisible=True, readonly=True) - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) - - # 整体式刀具型号 - cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '整体式刀具')]) - - # 刀片型号 - cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀片')]) - - # 刀杆型号 - cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀杆')]) - - # 刀盘型号 - cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀盘')]) - - # 刀柄型号 - cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀柄')]) - - # 夹头型号 - cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '夹头')]) - - diameter = fields.Float('直径(mm)', readonly=True) - tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') - machining_accuracy = fields.Float('加工精度(mm)', readonly=True) - tool_length = fields.Float('装刀长(mm)', readonly=True) - blade_number = fields.Integer('刃数', readonly=True) - integral_blade_length = fields.Float('整体刃长(mm)', readonly=True) - effective_blade_length = fields.Float('有效刃长(mm)', readonly=True) - max_life = fields.Float('最大寿命值', readonly=True) - is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀', readonly=True, - compute='_compute_functional_cutting_tool_id') - applicable_range = fields.Char('适用范围', readonly=True) - image = fields.Binary('图片', readonly=True) - - @api.depends('functional_cutting_tool_id') - def _compute_functional_cutting_tool_id(self): - if self.functional_cutting_tool_id: - self.tool_grade = self.functional_cutting_tool_id.tool_grade - self.is_standard = self.functional_cutting_tool_id.is_standard - - # 功能刀具出入库记录 特有字段 - current_state = fields.Char(string='当前状态', readonly=False) - current_store_area = fields.Char(string='当前库区', readonly=False) - current_store_place = fields.Char(string='当前库位', readonly=False) - tool_install_staff = fields.Char(string='装刀人', readonly=False) - tool_install_time = fields.Datetime(string='装刀时间', readonly=False) - thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False) - # max_life_span = fields.Char(string='最大寿命值', readonly=False) - alarm_value = fields.Char(string='报警值', readonly=False) - used_value = fields.Char(string='已使用值', readonly=False) - reason_application = fields.Char(string='申请原因', readonly=False) - applicant = fields.Char(string='申请人', readonly=False) - - inbound_and_outbound_records_ids = fields.One2many('sf.inbound.and.outbound.records', - 'inbound_and_outbound_tools_id', string='出入库记录') - - remark = fields.Char(string='备注/说明', readonly=False) - - -class InboundAndOutboundRecords(models.Model): - _name = 'sf.inbound.and.outbound.records' - _description = '出入库记录' - _order = 'id DESC' - - inbound_and_outbound_tools_id = fields.Many2one('sf.inbound.and.outbound.records.of.functional.tools', - string='功能刀具出入库记录') - - name = fields.Char(string='出入库记录') - tool_state = fields.Selection([('0', '领用出库'), ('1', '归还入库')], string="出入库类别", readonly=False) - receive_equipment = fields.Char(string='领用机台', readonly=False) - receive_staff = fields.Char(string='领用人', readonly=False) - receive_time = fields.Datetime(string='领用出库时间', readonly=False) - return_staff = fields.Char(string='归还人', readonly=False) - return_time = fields.Datetime(string='归还入库时间', readonly=False) - current_store_area = fields.Char(string='库区', readonly=False) - current_store_place = fields.Char(string='库位', readonly=False) - number = fields.Integer(string='数量', readonly=False) - - class MachineTableToolChangingApply(models.Model): _name = 'sf.machine.table.tool.changing.apply' _description = '机床换刀申请' @@ -390,12 +302,14 @@ class MachineTableToolChangingApply(models.Model): machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=False, required=True, domain="[('equipment_id', '=', maintenance_equipment_id)]") - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', - domain=[('product_id.name', '=', '功能刀具')]) - functional_tool_name = fields.Char(string='功能刀具名称') - functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', - domain=[('name', '=', '功能刀具')]) + functional_tool_name = fields.Char(string='刀具名称', related='functional_tool_name_id.name', store=True) + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', store=True, + domain=[('product_id.name', '=', '功能刀具')], + related='functional_tool_name_id.barcode_id') + functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, + related='functional_tool_name_id.functional_tool_type_id') + tool_position_interface_type = fields.Selection( [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), @@ -463,7 +377,7 @@ class MachineTableToolChangingApply(models.Model): :return: """ # 更新数据到机台换刀申请界面 - if self.functional_tool_status == '报警' and self.sf_functional_tool_assembly_id == False: + if self.functional_tool_status == '报警' and not self.sf_functional_tool_assembly_id: machine_table_tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( [('maintenance_equipment_id', '=', self.maintenance_equipment_id.id), ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id) @@ -601,9 +515,9 @@ class CAMWorkOrderProgramKnifePlan(models.Model): # 将计划执行状态改为执行中 self.env['sf.cam.work.order.program.knife.plan'].search( - [('barcode_id', '=', self.barcode_id.id)]).write({ - 'plan_execute_status': '1', - 'applicant': self.env.user.name}) + [('barcode_id', '=', self.barcode_id.id)]).write( + {'plan_execute_status': '1', + 'applicant': self.env.user.name}) def revocation(self): """ @@ -616,11 +530,10 @@ class CAMWorkOrderProgramKnifePlan(models.Model): # 将计划执行状态改为待执行,同时清除申请人、功能刀具组装字段数据 self.env['sf.cam.work.order.program.knife.plan'].search( - [('barcode_id', '=', self.barcode_id.id)]).write({ - 'plan_execute_status': '0', - 'applicant': None, - 'sf_functional_tool_assembly_id': None, - }) + [('barcode_id', '=', self.barcode_id.id)]).write( + {'plan_execute_status': '0', + 'applicant': None, + 'sf_functional_tool_assembly_id': None}) class FunctionalToolAssembly(models.Model): diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index fa10d0c5..cc72f699 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -2,8 +2,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1 access_sf_functional_tool_warning,sf.functional.tool.warning,model_sf_functional_tool_warning,base.group_user,1,1,1,1 access_sf_real_time_distribution_of_functional_tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,base.group_user,1,1,1,1 -access_sf_inbound_and_outbound_records_of_functional_tools,sf.inbound.and.outbound.records.of.functional.tools,model_sf_inbound_and_outbound_records_of_functional_tools,base.group_user,1,1,1,1 -access_sf_inbound_and_outbound_records,sf.inbound.and.outbound.records,model_sf_inbound_and_outbound_records,base.group_user,1,1,1,1 access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,base.group_user,1,1,1,1 access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,base.group_user,1,1,1,1 diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index efa4feee..c1fc939b 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -25,15 +25,15 @@ /> -

@@ -416,136 +424,43 @@ 功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools + stock.move.line - - - - - - - - - - - - - + + + + + + + + + + + - - 功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools - -
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools + stock.move.line - + + - - - - - - - - - - - + + + + + + + + - + @@ -554,62 +469,13 @@ 功能刀具出入库记录 ir.actions.act_window - sf.inbound.and.outbound.records.of.functional.tools - tree,form,search - - - - - - 出入库记录 - sf.inbound.and.outbound.records - - - - - - - - - - - - - - - - - 出入库记录 - sf.inbound.and.outbound.records - -
- - - - - - - - - - - - - - - - - - -
-
-
- - - 出入库记录 - ir.actions.act_window - sf.inbound.and.outbound.records - tree,form + stock.move.line + tree,search + + + [('functional_tool_name_id', '!=', False)] @@ -624,7 +490,7 @@ - + @@ -639,9 +505,8 @@ - - +