Skip to content

Commit

Permalink
[FIX] merge_records: Avoid error on empty filtered list
Browse files Browse the repository at this point in the history
On date/datetimes fields, the list is pre-filtered for avoiding empty elements.
If all the list is empty, then we can get an error executing `min([])` or `max([])`.
We prevent it this way.

Closes OCA/OpenUpgrade#2324
  • Loading branch information
pedrobaeza authored Apr 27, 2020
1 parent 5651e38 commit 6c18ce0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion openupgradelib/openupgrade_merge_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def _adjust_merged_values_orm(env, model_name, record_ids, target_record_id,
elif field.type in ('date', 'datetime'):
if op:
_list = filter(lambda x: x is not False, _list)
op = op or 'other'
op = _list and op or 'other'
if op == 'max':
vals[field.name] = max(_list)
elif op == 'min':
Expand Down

0 comments on commit 6c18ce0

Please sign in to comment.