From 70f6a94537484873cf2f262aa75310cde4379d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 14 Oct 2024 17:55:20 +0200 Subject: [PATCH] Optimize searching stock moves with FIFO quantity when deleting --- modules/product_cost_fifo/move.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/product_cost_fifo/move.py b/modules/product_cost_fifo/move.py index e4169ad1bf..8c2f54fde7 100644 --- a/modules/product_cost_fifo/move.py +++ b/modules/product_cost_fifo/move.py @@ -152,15 +152,12 @@ class Move(metaclass=PoolMeta): @classmethod def delete(cls, moves): - fifo_moves = cls.search([ - ('id', 'in', [m.id for m in moves]), - ('fifo_quantity', '!=', 0.0), - ]) - if fifo_moves: - raise AccessError( - gettext('product_cost_fifo.msg_move_delete_fifo', - move=fifo_moves[0].rec_name)) - super(Move, cls).delete(moves) + for move in moves: + if move.fifo_quantity: + raise AccessError( + gettext('product_cost_fifo.msg_move_delete_fifo', + move=move.rec_name)) + super().delete(moves) @classmethod def copy(cls, moves, default=None):