diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 8673d370..b00ab209 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -769,6 +769,15 @@ class FunctionalToolDismantle(models.Model): chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位', domain="[('product_id', 'in', (chuck_product_id, False))]") + @api.onchange('functional_tool_id') + def _onchange_freight(self): + for item in self: + item.integral_freight_id = False + item.blade_freight_id = False + item.bar_freight_id = False + item.pad_freight_id = False + item.chuck_freight_id = False + @api.depends('functional_tool_id') def _compute_functional_tool_num(self): for item in self: @@ -807,7 +816,7 @@ class FunctionalToolDismantle(models.Model): raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle) location = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) location_dest = self.env['stock.location'].search([('name', '=', '刀具房')]) - # =================刀柄是否报废拆解======= + # =================刀柄是否[报废]拆解======= location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')]) if self.handle_rfid: lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)]) @@ -822,34 +831,34 @@ class FunctionalToolDismantle(models.Model): # 刀柄不报废 入库到刀具房 lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解', functional_tool_assembly, functional_tool_assembly.tool_groups_id) - # ==============功能刀具报废拆解================ + # ==============功能刀具[报废]拆解================ if self.dismantle_cause in ['寿命到期报废', '崩刀报废']: # 除刀柄外物料报废 入库到Scrap - if self.integral_freight_id: + if self.integral_product_id: self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - elif self.blade_freight_id: + elif self.blade_product_id: self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - if self.bar_freight_id: + if self.bar_product_id: self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - elif self.pad_freight_id: + elif self.pad_product_id: self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - if self.chuck_freight_id: + if self.chuck_product_id: self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - # ===========功能刀具磨削拆解============== + # ===========功能刀具[磨削]拆解============== elif self.dismantle_cause in ['刀具需磨削']: location_dest = self.env['stock.location'].search([('name', '=', '磨削房')]) # 除刀柄外物料拆解 入库到具体库位 - if self.integral_freight_id: + if self.integral_product_id: self.integral_product_id.dismantle_stock_moves(False, location, location_dest) - elif self.blade_freight_id: + elif self.blade_product_id: self.blade_product_id.dismantle_stock_moves(False, location, location_dest) - if self.bar_freight_id: + if self.bar_product_id: self.bar_product_id.dismantle_stock_moves(False, location, location_dest) - elif self.pad_freight_id: + elif self.pad_product_id: self.pad_product_id.dismantle_stock_moves(False, location, location_dest) - if self.chuck_freight_id: + if self.chuck_product_id: self.chuck_product_id.dismantle_stock_moves(False, location, location_dest) - # ==============功能刀具更换拆解============== + # ==============功能刀具[更换]拆解============== elif self.dismantle_cause in ['更换为其他刀具']: # 除刀柄外物料拆解 入库到具体库位 if self.integral_freight_id: @@ -877,7 +886,7 @@ class FunctionalToolDismantle(models.Model): 'rfid': '', 'state': '已拆解' }) - logging.info('刀具拆解成功!') + logging.info('【%s】刀具拆解成功!' % self.name) class ProductProduct(models.Model): @@ -897,12 +906,12 @@ class ProductProduct(models.Model): location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)]) location.product_num = location.product_num + 1 else: - location = False + location = self.env['sf.shelf.location'] # 创建移动历史记录 stock_move_line_id = self.env['stock.move.line'].sudo().create({ 'product_id': self.id, 'move_id': stock_move_id.id, - 'current_location_id': location.id or False, + 'current_location_id': location.id, 'install_tool_time': fields.Datetime.now(), 'qty_done': 1.0, 'state': 'done', diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index e907144d..61bbd110 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -846,7 +846,8 @@ attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])], 'readonly': [('state', '=', '已拆解')]}"/> - + @@ -855,7 +856,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('chuck_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -869,7 +871,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('integral_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -884,7 +887,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('blade_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -896,7 +900,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('bar_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -908,7 +913,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('pad_freight_id', '!=', False), ('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml index 90783fca..2f6317b9 100644 --- a/sf_warehouse/views/shelf_location.xml +++ b/sf_warehouse/views/shelf_location.xml @@ -246,6 +246,7 @@ +