Skip to content

Commit

Permalink
[FIX] stock: traceback when there is no delveries for a lot
Browse files Browse the repository at this point in the history
Fixes 38bfbed
We cannot create a `set` from `None`
```
   File "/home/odoo/src/odoo/15.0/addons/stock/models/stock_production_lot.py", line 225, in <listcomp>
    delivery_ids.update(*[set(delivery_by_lot.get(lot_id)) for lot_id in (producing_move_lines.produce_line_ids.lot_id - next_lots).ids])
 TypeError: 'NoneType' object is not iterable
```
Small optimization: no need to create a list that's immediately unpacked.

This error was detected during upgrades.
upg-360084

closes odoo#95398

X-original-commit: 1870ef4
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Alvaro Fuentes Suarez (afu) <afu@odoo.com>
  • Loading branch information
aj-fuentes committed Jul 6, 2022
1 parent 6c0744d commit 2ba68a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/stock/models/stock_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _find_delivery_ids_by_lot(self, lot_path=None, delivery_by_lot=None):
next_lots_ids = set(next_lots.ids)
# If some producing lots are in lot_path, it means that they have been previously processed.
# Their results are therefore already in delivery_by_lot and we add them to delivery_ids directly.
delivery_ids.update(*[set(delivery_by_lot.get(lot_id)) for lot_id in (producing_move_lines.produce_line_ids.lot_id - next_lots).ids])
delivery_ids.update(*(delivery_by_lot.get(lot_id, []) for lot_id in (producing_move_lines.produce_line_ids.lot_id - next_lots).ids))

for lot_id, delivery_ids_set in next_lots._find_delivery_ids_by_lot(lot_path=lot_path, delivery_by_lot=delivery_by_lot).items():
if lot_id in next_lots_ids:
Expand Down

0 comments on commit 2ba68a2

Please sign in to comment.