From f2482b5128b2274bc36c4fa28eec741b1949e48a Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 22 Oct 2024 13:45:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E4=BA=A7=E7=94=9F=E5=BA=93=E5=AD=98=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=B2=A1=E6=9C=89=E5=AE=9E=E6=97=B6=E5=8F=91=E7=94=9F?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/functional_tool.py | 4 +++- sf_tool_management/models/stock.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index e8523cd3..78a652f4 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -51,6 +51,8 @@ class FunctionalCuttingToolEntity(models.Model): string='位置', compute='_compute_current_location_id', store=True) image = fields.Binary('图片', readonly=True) + stock_num = fields.Integer('库存变更次数', default=0) + safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools', string='功能刀具安全库存', readonly=True) @@ -71,7 +73,7 @@ class FunctionalCuttingToolEntity(models.Model): }) @api.depends('barcode_id.quant_ids', 'barcode_id.quant_ids.location_id', 'functional_tool_status', - 'current_shelf_location_id') + 'current_shelf_location_id', 'stock_num') def _compute_current_location_id(self): for record in self: if record.functional_tool_status == '已拆除': diff --git a/sf_tool_management/models/stock.py b/sf_tool_management/models/stock.py index 9f0d9f82..92198239 100644 --- a/sf_tool_management/models/stock.py +++ b/sf_tool_management/models/stock.py @@ -53,6 +53,13 @@ class StockMoveLine(models.Model): [('barcode_id', '=', line_id.lot_id.id), ('functional_tool_status', '=', '正常')]).cnc_function_tool_use_verify() + for move_line in move_lines: + if move_line.lot_id: + tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search( + [('barcode_id', '=', move_line.lot_id.id), + ('functional_tool_status', '=', '正常')]) + tool_id.stock_num += tool_id.stock_num + class StockPicking(models.Model): _inherit = 'stock.picking'