diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 01c3de46..83b4b550 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -422,11 +422,12 @@ class FunctionalToolAssembly(models.Model): @api.depends('integral_freight_barcode') def _compute_integral_product_id(self): for item in self: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.integral_freight_barcode)]) - if location: - item.integral_product_id = location.product_id.id - else: - item.integral_product_id = False + if 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: + item.integral_product_id = False # =================刀片型号============= blade_freight_barcode = fields.Char('刀片货位') @@ -441,11 +442,12 @@ class FunctionalToolAssembly(models.Model): @api.depends('blade_freight_barcode') def _compute_blade_product_id(self): for item in self: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)]) - if location: - item.blade_product_id = location.product_id.id - else: - item.blade_product_id = False + if item.integral_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 + else: + item.blade_product_id = False # ==============刀杆型号================ bar_freight_barcode = fields.Char('刀杆货位') @@ -460,11 +462,12 @@ class FunctionalToolAssembly(models.Model): @api.depends('bar_freight_barcode') def _compute_bar_product_id(self): for item in self: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)]) - if location: - item.bar_product_id = location.product_id.id - else: - item.bar_product_id = False + if item.integral_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 + else: + item.bar_product_id = False # =============刀盘型号================ pad_freight_barcode = fields.Char('刀盘货位') @@ -479,11 +482,12 @@ class FunctionalToolAssembly(models.Model): @api.depends('pad_freight_barcode') def _compute_pad_product_id(self): for item in self: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)]) - if location: - item.pad_product_id = location.product_id.id - else: - item.pad_product_id = False + if item.integral_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 + else: + item.pad_product_id = False # ==============刀柄型号============== handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_handle_product_id', store=True) @@ -519,11 +523,12 @@ class FunctionalToolAssembly(models.Model): @api.depends('chuck_freight_barcode') def _compute_chuck_product_id(self): for item in self: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)]) - if location: - item.chuck_product_id = location.product_id.id - else: - item.chuck_product_id = False + if item.integral_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 + else: + item.chuck_product_id = False # ==================待删除字段================== blade_name = fields.Char('') diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml index a0e1a5c1..90783fca 100644 --- a/sf_warehouse/views/shelf_location.xml +++ b/sf_warehouse/views/shelf_location.xml @@ -129,16 +129,16 @@