From 06842c6df9f9fa320a9f01506db802629c7d7647 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 26 Dec 2024 10:01:42 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93?= =?UTF-8?q?=EF=BC=8C=E9=80=89=E5=8F=96=E7=9B=AE=E6=A0=87=E8=B4=A7=E4=BD=8D?= =?UTF-8?q?=E5=8E=BB=E9=87=8D=E6=A0=A1=E9=AA=8C=E4=BC=98=E5=8C=96=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E8=B4=A7=E4=BD=8D=E7=9A=84=E5=80=BC=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/functional_tool.py | 7 ++++++- sf_warehouse/models/model.py | 7 +++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 78a652f4..63a31b82 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -45,7 +45,8 @@ class FunctionalCuttingToolEntity(models.Model): string='状态', store=True, default='正常') current_location_id = fields.Many2one('stock.location', string='当前位置', compute='_compute_current_location_id', store=True) - current_shelf_location_id = fields.Many2one('sf.shelf.location', string='当前货位', readonly=True) + current_shelf_location_id = fields.Many2one('sf.shelf.location', string='当前货位', + compute='_compute_current_location_id', store=True) current_location = fields.Selection( [('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')], string='位置', compute='_compute_current_location_id', store=True) @@ -85,6 +86,10 @@ class FunctionalCuttingToolEntity(models.Model): if quant_id.inventory_quantity_auto_apply > 0: record.current_location_id = quant_id.location_id if quant_id.location_id.name == '制造前': + shelf_location_id = self.env['sf.shelf.location'].sudo().search([ + ('product_sn_id', '=', record.barcode_id.id)]) + if shelf_location_id: + record.current_shelf_location_id = shelf_location_id.id if not record.current_shelf_location_id: record.current_location = '机内刀库' else: diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 30024239..4e8e5af6 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -888,12 +888,11 @@ class SfStockMoveLine(models.Model): def _check_destination_location_id(self): for item in self: if item: - i = 0 barcode = item.destination_location_id.barcode for line in item.picking_id.move_line_ids_without_package: - if barcode and barcode == line.destination_location_id.barcode: - i += 1 - if i > 1: + if line.destination_location_id: + if (barcode and barcode == line.destination_location_id.barcode + and item.product_id != line.product_id): raise ValidationError( '【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)