[FIX] gamification: user_domain issue with not all

The field user_domain allow to get the list of users for which a
challenge is applied. The javascript framework for a char_domain widget
sends a JSON list to the server, but the server saved it as a string in
a Char field.

Hence we can have a list (in values received by write or create) or a
string (when getting the field value of a record).

Since 0c649644db this caused an error when user_domain was not empty.

This commit solves it by having _get_challenger_users always receiving a
string.

opw-708177
This commit is contained in:
Nicolas Lempereur
2017-02-13 12:34:58 +01:00
parent 7c8a721a96
commit 83b6b71e29
+3 -2
View File
@@ -7,6 +7,7 @@ from datetime import date, timedelta
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__)
@@ -158,7 +159,7 @@ class Challenge(models.Model):
"""Overwrite the create method to add the user of groups"""
if vals.get('user_domain'):
users = self._get_challenger_users(vals.get('user_domain'))
users = self._get_challenger_users(ustr(vals.get('user_domain')))
if not vals.get('user_ids'):
vals['user_ids'] = []
@@ -169,7 +170,7 @@ class Challenge(models.Model):
@api.multi
def write(self, vals):
if vals.get('user_domain'):
users = self._get_challenger_users(vals.get('user_domain'))
users = self._get_challenger_users(ustr(vals.get('user_domain')))
if not vals.get('user_ids'):
vals['user_ids'] = []