Skip to content

Commit 476d804

Browse files
committed
sale_stock_available_to_promise_release: improve '_get_next_replenishment_date' perf
Checking ongoing states instead of finished ones (done and canceled) helps PostgreSQL to perform the filter on far less lines (done lines are increasing a lot over time), speeding up the query to get the next replenishment date.
1 parent c114af4 commit 476d804

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

sale_stock_available_to_promise_release/models/product_product.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ def _get_next_replenishment_date(self):
1212
move_line = self.env["stock.move"].search(
1313
[
1414
("product_id", "=", self.id),
15-
("state", "not in", ["done", "cancel"]),
15+
(
16+
"state",
17+
"in",
18+
[
19+
"draft",
20+
"waiting",
21+
"confirmed",
22+
"partially_available",
23+
"assigned",
24+
],
25+
),
1626
("picking_type_id.code", "=", "incoming"),
1727
],
1828
limit=1,

0 commit comments

Comments
 (0)