Skip to content

Commit

Permalink
sale_stock_available_to_promise_release: improve '_get_next_replenish…
Browse files Browse the repository at this point in the history
…ment_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.
  • Loading branch information
sebalix committed Mar 22, 2024
1 parent c114af4 commit dbff044
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ def _get_next_replenishment_date(self):
move_line = self.env["stock.move"].search(
[
("product_id", "=", self.id),
("state", "not in", ["done", "cancel"]),
(
"state",
"in",
(
"draft",
"waiting",
"confirmed",
"partially_available",
"assigned",
),
),
("picking_type_id.code", "=", "incoming"),
],
limit=1,
Expand Down

0 comments on commit dbff044

Please sign in to comment.