diff options
| author | xmo-odoo <xmo@odoo.com> | 2017-05-10 09:39:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 09:39:55 +0200 |
| commit | fffaf735f58f1ac57781c095eb552de6d1fcdc47 (patch) | |
| tree | 88ab0ab65430d871862a836524e0ecc890d1674d /addons/gamification/models | |
| parent | 10eee18a047d35305dc46282e610e88936d81ffc (diff) | |
[FIX] P3: list -> iterable builtins (#16811)
In Python 3:
* various builtins and dict methods were changed to return
view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
removed altogether
This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).
Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.
issue #8530
Diffstat (limited to 'addons/gamification/models')
| -rw-r--r-- | addons/gamification/models/goal.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py index 5a306ae9a33..89f037d55d3 100644 --- a/addons/gamification/models/goal.py +++ b/addons/gamification/models/goal.py @@ -260,7 +260,7 @@ class Goal(models.Model): for goal in self: goals_by_definition.setdefault(goal.definition_id, []).append(goal) - for definition, goals in goals_by_definition.items(): + for definition, goals in pycompat.items(goals_by_definition): goals_to_write = {} if definition.computation_mode == 'manually': for goal in goals: @@ -305,9 +305,9 @@ class Goal(models.Model): subqueries.setdefault((start_date, end_date), {}).update({goal.id:safe_eval(definition.batch_user_expression, {'user': goal.user_id})}) # the global query should be split by time periods (especially for recurrent goals) - for (start_date, end_date), query_goals in subqueries.items(): + for (start_date, end_date), query_goals in pycompat.items(subqueries): subquery_domain = list(general_domain) - subquery_domain.append((field_name, 'in', list(set(query_goals.values())))) + subquery_domain.append((field_name, 'in', list(set(pycompat.values(query_goals))))) if start_date: subquery_domain.append((field_date_name, '>=', start_date)) if end_date: @@ -351,7 +351,7 @@ class Goal(models.Model): goals_to_write.update(goal._get_write_values(new_value)) - for goal, values in goals_to_write.iteritems(): + for goal, values in pycompat.items(goals_to_write): if not values: continue goal.write(values) |
