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