Skip to content

Commit

Permalink
s_available_to_promise_release: fix picking w/out move lines
Browse files Browse the repository at this point in the history
When computing date_priority, if a picking has no move lines or some
move lines have no date_priority, we can have errors because min()
is called without sequence or compares bool and datetime.
  • Loading branch information
guewen authored and sebastienbeau committed Jan 6, 2021
1 parent 519ee74 commit ed18b7b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stock_available_to_promise_release/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ def _search_release_ready(self, operator, value):
@api.depends("move_lines.date_priority")
def _compute_date_priority(self):
for picking in self:
picking.date_priority = min(picking.move_lines.mapped("date_priority"))
dates = [
date_priority
for date_priority in picking.move_lines.mapped("date_priority")
if date_priority
]
picking.date_priority = min(dates) if dates else False

def release_available_to_promise(self):
# When the stock.picking form view is opened through the "Deliveries"
Expand Down

0 comments on commit ed18b7b

Please sign in to comment.