Skip to content

Commit

Permalink
[IMP] stock_available_to_promise_release: Make previous sql hookable
Browse files Browse the repository at this point in the history
  • Loading branch information
mt-software-de committed Oct 21, 2023
1 parent 232e040 commit 100249b
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions stock_available_to_promise_release/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,35 @@ def _previous_promised_qty_sql_main_query(self):
GROUP BY move.id;
"""

def _previous_promised_qty_sql_moves_before_matches(self):
return "COALESCE(m.need_release, False) = COALESCE(move.need_release, False)"

def _previous_promised_qty_sql_moves_before(self):
sql = """
m.priority > move.priority
OR
(
m.priority = move.priority
AND m.date_priority < move.date_priority
)
OR (
m.priority = move.priority
AND m.date_priority = move.date_priority
AND m.picking_type_id = move.picking_type_id
AND m.id < move.id
)
OR (
m.priority = move.priority
AND m.date_priority = move.date_priority
AND m.picking_type_id != move.picking_type_id
AND m.id > move.id
{moves_matches}
AND (
m.priority > move.priority
OR
(
m.priority = move.priority
AND m.date_priority < move.date_priority
)
OR (
m.priority = move.priority
AND m.date_priority = move.date_priority
AND m.picking_type_id = move.picking_type_id
AND m.id < move.id
)
OR (
m.priority = move.priority
AND m.date_priority = move.date_priority
AND m.picking_type_id != move.picking_type_id
AND m.id > move.id
)
)
"""
""".format(
moves_matches=self._previous_promised_qty_sql_moves_before_matches()
)
return sql

def _previous_promised_qty_sql_lateral_where(self):
Expand All @@ -177,10 +185,7 @@ def _previous_promised_qty_sql_lateral_where(self):
AND p_type.code = 'outgoing'
AND loc.parent_path LIKE ANY(%(location_paths)s)
AND (
COALESCE(m.need_release, False) = COALESCE(move.need_release, False)
AND (
{moves_before}
)
{moves_before}
OR (
move.need_release IS true
AND (m.need_release IS false OR m.need_release IS null)
Expand Down

0 comments on commit 100249b

Please sign in to comment.