From 6c18ce0c160b9cf47c4fa898d9b6c4265d98c216 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 27 Apr 2020 14:38:33 +0200 Subject: [PATCH] [FIX] merge_records: Avoid error on empty filtered list 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 --- openupgradelib/openupgrade_merge_records.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openupgradelib/openupgrade_merge_records.py b/openupgradelib/openupgrade_merge_records.py index fba3fba2..698b6bf7 100644 --- a/openupgradelib/openupgrade_merge_records.py +++ b/openupgradelib/openupgrade_merge_records.py @@ -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':