From 0c46e36c315b4c3fc51f8da4edd60f10bfc22983 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Tue, 22 Nov 2022 12:07:52 +0100 Subject: [PATCH] [IMP] stock_move_auto_assign: Extract SQL locking logic into a dedicated method --- stock_move_auto_assign/models/product_product.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stock_move_auto_assign/models/product_product.py b/stock_move_auto_assign/models/product_product.py index 6251c2a9f..051a87180 100644 --- a/stock_move_auto_assign/models/product_product.py +++ b/stock_move_auto_assign/models/product_product.py @@ -46,6 +46,10 @@ class ProductProduct(models.Model): pickings = moves.picking_id if not pickings: return + self._lock_pickings_or_retry(pickings) + moves._action_assign() + + def _lock_pickings_or_retry(self, pickings): try: self.env.cr.execute( "SELECT id FROM stock_picking WHERE id IN %s FOR UPDATE NOWAIT", @@ -62,4 +66,3 @@ class ProductProduct(models.Model): "Could not obtain lock on transfers, will retry.", ignore_retry=True ) from err raise - moves._action_assign()