[IMP] stock_move_auto_assign: Extract SQL locking logic into a dedicated method

This commit is contained in:
Laurent Mignon (ACSONE)
2022-11-22 12:07:52 +01:00
parent dea52bdf5d
commit 0c46e36c31

View File

@@ -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()