@@ -313,14 +313,23 @@ def _is_release_needed(self):
313
313
def _is_release_ready (self ):
314
314
"""Checks if a move itself is ready for release
315
315
without considering the picking release_ready
316
+
317
+
318
+ Be careful, when calling this method, you must ensure that the
319
+ 'ordered_available_to_promise_qty' field is up to date. If not,
320
+ you should invalidate the cache before calling this method. This
321
+ is not done automatically to avoid unnecessary cache invalidation
322
+ and to allow batch computation. The `_is_release_ready` method
323
+ is designed to be called on a single record. If we do the cache
324
+ invalidation here, it would be done for each record, which means
325
+ that the computation of the 'ordered_available_to_promise_qty'
326
+ would be done for each record, which is not efficient.
316
327
"""
317
328
self .ensure_one ()
318
329
if not self ._is_release_needed () or self .state == "draft" :
319
330
return False
320
331
release_policy = self .picking_id .release_policy
321
332
rounding = self .product_id .uom_id .rounding
322
- # computed field has no depends set, invalidate cache before reading
323
- self .invalidate_recordset (["ordered_available_to_promise_qty" ])
324
333
ordered_available_to_promise_qty = self .ordered_available_to_promise_qty
325
334
if release_policy == "one" :
326
335
return (
@@ -349,6 +358,7 @@ def _get_release_ready_depends(self):
349
358
350
359
@api .depends (lambda self : self ._get_release_ready_depends ())
351
360
def _compute_release_ready (self ):
361
+ self .invalidate_recordset (["ordered_available_to_promise_qty" ])
352
362
for move in self :
353
363
release_ready = move ._is_release_ready ()
354
364
if release_ready and move .picking_id .release_policy == "one" :
0 commit comments