diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 83b4b550..235935a0 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -423,7 +423,8 @@ class FunctionalToolAssembly(models.Model): def _compute_integral_product_id(self): for item in self: if item.integral_freight_barcode: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.integral_freight_barcode)]) + location = self.env['sf.shelf.location'].sudo().search( + [('barcode', '=', item.integral_freight_barcode)]) if location: item.integral_product_id = location.product_id.id else: @@ -442,7 +443,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('blade_freight_barcode') def _compute_blade_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.blade_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)]) if location: item.blade_product_id = location.product_id.id @@ -462,7 +463,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('bar_freight_barcode') def _compute_bar_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.bar_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)]) if location: item.bar_product_id = location.product_id.id @@ -482,7 +483,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('pad_freight_barcode') def _compute_pad_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.pad_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)]) if location: item.pad_product_id = location.product_id.id @@ -523,7 +524,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('chuck_freight_barcode') def _compute_chuck_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.chuck_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)]) if location: item.chuck_product_id = location.product_id.id @@ -631,3 +632,120 @@ class FunctionalToolAssembly(models.Model): code = self._get_code(obj.loading_task_source) obj.assembly_order_code = code return obj + + +class FunctionalToolDismantle(models.Model): + _name = 'sf.functional.tool.dismantle' + _inherit = ["barcodes.barcode_events_mixin"] + _description = '功能刀具拆解' + + def on_barcode_scanned(self, barcode): + """ + 扫码 + """ + tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', barcode)]) + if tool_id: + self.functional_tool_id = tool_id.id + else: + pass + + name = fields.Char('名称', related='functional_tool_id.name') + + functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True, + domain=[('functional_tool_status', '!=', '已拆除')]) + tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, + compute='_compute_functional_tool_num') + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True) + diameter = fields.Integer(string='刀具直径(mm)', compute='_compute_functional_tool_num', store=True) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_functional_tool_num', store=True) + rfid = fields.Char('Rfid', compute='_compute_functional_tool_num', store=True) + + dismantle_cause = fields.Selection( + [('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'), + ('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True) + dismantle_data = fields.Datetime('拆解日期', readonly=True) + dismantle_person = fields.Char('拆解人', readonly=True) + image = fields.Binary('图片', readonly=True) + + scrap_id = fields.Char('报废单号') + grinding_id = fields.Char('磨削单号') + + # 刀柄 + handle_product_id = fields.Many2one('product.product', string='刀柄', compute='_compute_functional_tool_num', + store=True) + handle_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', + related='handle_product_id.cutting_tool_model_id') + handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id') + handle_rfid = fields.Char(string='刀柄Rfid') + scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False) + + # 整体式 + integral_product_id = fields.Many2one('product.product', string='整体式刀具', + compute='_compute_functional_tool_num', store=True) + integral_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', + related='integral_product_id.cutting_tool_model_id') + integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', + related='integral_product_id.brand_id') + integral_freight_barcode = fields.Char('整体式刀具目标货位') + + # 刀片 + blade_product_id = fields.Many2one('product.product', string='刀片', compute='_compute_functional_tool_num', + store=True) + blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', + related='blade_product_id.cutting_tool_model_id') + blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id') + blade_freight_barcode = fields.Char('刀片目标货位') + + # 刀杆 + bar_product_id = fields.Many2one('product.product', string='刀杆', compute='_compute_functional_tool_num', + store=True) + bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', + related='bar_product_id.cutting_tool_model_id') + bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id') + bar_freight_barcode = fields.Char('刀杆目标货位') + + # 刀盘 + pad_product_id = fields.Many2one('product.product', string='刀盘', compute='_compute_functional_tool_num', + store=True) + pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', + related='pad_product_id.cutting_tool_model_id') + pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id') + pad_freight_barcode = fields.Char('刀盘目标货位') + + # 夹头 + chuck_product_id = fields.Many2one('product.product', string='夹头', compute='_compute_functional_tool_num', + store=True) + chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', + related='chuck_product_id.cutting_tool_model_id') + chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id') + chuck_freight_barcode = fields.Char('夹头目标货位') + + @api.depends('functional_tool_id') + def _compute_functional_tool_num(self): + for item in self: + if item.functional_tool_id: + item.tool_groups_id = item.functional_tool_id.tool_groups_id.id + item.tool_type_id = item.functional_tool_id.sf_cutting_tool_type_id.id + item.diameter = item.functional_tool_id.functional_tool_diameter + item.knife_tip_r_angle = item.functional_tool_id.knife_tip_r_angle + item.rfid = item.functional_tool_id.rfid + + item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id + item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id + item.blade_product_id = item.functional_tool_id.functional_tool_name_id.blade_product_id.id + item.bar_product_id = item.functional_tool_id.functional_tool_name_id.bar_product_id.id + item.pad_product_id = item.functional_tool_id.functional_tool_name_id.pad_product_id.id + item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id + else: + item.tool_groups_id = False + item.tool_type_id = False + item.diameter = 0 + item.knife_tip_r_angle = 0 + item.rfid = '' + + item.handle_product_id = False + item.integral_product_id = False + item.blade_product_id = False + item.bar_product_id = False + item.pad_product_id = False + item.chuck_product_id = False diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index 3a7b4589..79800637 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -30,4 +30,8 @@ access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_se access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0 access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_order_user,1,0,0,0 -access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0 \ No newline at end of file +access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0 + + +access_sf_functional_tool_dismantle_group_sf_tool_user,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_sf_tool_user,1,1,1,0 +access_sf_functional_tool_dismantle_group_plan_dispatch,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_plan_dispatch,1,0,0,0 diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index 13a12725..eae7532e 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -78,5 +78,13 @@ parent="menu_sf_tool_manage" /> + + diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 46c77b82..4e1a6fc4 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -766,5 +766,148 @@ {'search_default_no_assemble_status':1} + + + + + 功能刀具拆解 + sf.functional.tool.dismantle + + + + + + + + + + + + + + + + + 功能刀具拆解 + sf.functional.tool.dismantle + +
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + sf.functional.tool.dismantle + + + + + + + + + + + + + 功能刀具拆解 + ir.actions.act_window + sf.functional.tool.dismantle + tree,form,search + + + + + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 979d8efe..be31d7f0 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -243,11 +243,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('integral_freight_barcode') def _compute_integral_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)]) - if location: - self.integral_product_id = location.product_id.id - else: - self.integral_product_id = False + if self.integral_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)]) + if location: + self.integral_product_id = location.product_id.id + else: + self.integral_product_id = False # ===============刀片型号==================== blade_freight_barcode = fields.Char('刀片货位') @@ -261,11 +262,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('blade_freight_barcode') def _compute_blade_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)]) - if location: - self.blade_product_id = location.product_id.id - else: - self.blade_product_id = False + if self.blade_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)]) + if location: + self.blade_product_id = location.product_id.id + else: + self.blade_product_id = False # ====================刀杆型号================== bar_freight_barcode = fields.Char('刀杆货位') @@ -279,11 +281,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('bar_freight_barcode') def _compute_bar_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)]) - if location: - self.bar_product_id = location.product_id.id - else: - self.bar_product_id = False + if self.bar_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)]) + if location: + self.bar_product_id = location.product_id.id + else: + self.bar_product_id = False # ===============刀盘型号=================== pad_freight_barcode = fields.Char('刀盘货位') @@ -297,11 +300,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('pad_freight_barcode') def _compute_pad_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)]) - if location: - self.pad_product_id = location.product_id.id - else: - self.pad_product_id = False + if self.pad_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)]) + if location: + self.pad_product_id = location.product_id.id + else: + self.pad_product_id = False # ================刀柄型号=============== handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid') @@ -335,11 +339,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('chuck_freight_barcode') def _compute_chuck_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)]) - if location: - self.chuck_product_id = location.product_id.id - else: - self.chuck_product_id = False + if self.chuck_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)]) + if location: + self.chuck_product_id = location.product_id.id + else: + self.chuck_product_id = False # ========================================