[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:
@@ -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'] = []
|
||||
|
||||
Reference in New Issue
Block a user