summaryrefslogtreecommitdiff
path: root/addons/gamification/models
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2020-01-22 15:16:22 +0000
committerMartin Trigaux <mat@odoo.com>2020-01-28 13:58:05 +0000
commita74a6480302620be364d2d15717fce59db3ddf4e (patch)
treeea350f32d91ceb078c4de5efd754bc15c08b450b /addons/gamification/models
parent41a465bc869a96b7a4e2b49a691360827019b0ea (diff)
[IMP] *: use ast.literal_eval
When simply need to parse a domain, it is easier Add .strip() on ir.ui.view as ast.literal_eval produces an syntax error if the node starts with spaces (as done in the xpath of hr_attendance.view_employee_form_inherit_hr_attendance) closes odoo/odoo#43831 Related: odoo/enterprise#7894 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/gamification/models')
-rw-r--r--addons/gamification/models/challenge.py5
-rw-r--r--addons/gamification/models/goal.py3
2 files changed, 4 insertions, 4 deletions
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 50254967205..b2fb80e7389 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import ast
import itertools
import logging
from datetime import date, timedelta
@@ -8,7 +9,6 @@ from dateutil.relativedelta import relativedelta, MO
from odoo import api, models, fields, _, exceptions
from odoo.tools import ustr
-from odoo.tools.safe_eval import safe_eval
_logger = logging.getLogger(__name__)
@@ -283,8 +283,7 @@ class Challenge(models.Model):
return True
def _get_challenger_users(self, domain):
- # FIXME: literal_eval?
- user_domain = safe_eval(domain)
+ user_domain = ast.literal_eval(domain)
return self.env['res.users'].search(user_domain)
def _recompute_challenge_users(self):
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py
index 80803449897..51fa991d6d1 100644
--- a/addons/gamification/models/goal.py
+++ b/addons/gamification/models/goal.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import ast
import logging
import time
from datetime import date, datetime, timedelta
@@ -292,7 +293,7 @@ class Goal(models.Model):
field_date_name = definition.field_date_id.name
if definition.computation_mode == 'count' and definition.batch_mode:
# batch mode, trying to do as much as possible in one request
- general_domain = safe_eval(definition.domain)
+ general_domain = ast.literal_eval(definition.domain)
field_name = definition.batch_distinctive_field.name
subqueries = {}
for goal in goals: