diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml
index 1169d5ef7c3..b4578c9b035 100644
--- a/addons/account_voucher/voucher_payment_receipt_view.xml
+++ b/addons/account_voucher/voucher_payment_receipt_view.xml
@@ -334,7 +334,7 @@
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py
index 266e25a5eb8..041c6ae169c 100644
--- a/addons/gamification/models/goal.py
+++ b/addons/gamification/models/goal.py
@@ -129,6 +129,36 @@ class gamification_goal_definition(osv.Model):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return self.pool.get('mail.followers').search(cr, uid, [('res_model', '=', model_name), ('partner_id', '=', user.partner_id.id)], count=True, context=context)
+ def _check_domain_validity(self, cr, uid, ids, context=None):
+ # take admin as should always be present
+ superuser = self.pool['res.users'].browse(cr, uid, SUPERUSER_ID, context=context)
+ for definition in self.browse(cr, uid, ids, context=context):
+ if definition.computation_mode not in ('count', 'sum'):
+ continue
+
+ obj = self.pool[definition.model_id.model]
+ try:
+ domain = safe_eval(definition.domain, {'user': superuser})
+ # demmy search to make sure the domain is valid
+ obj.search(cr, uid, domain, context=context, count=True)
+ except (ValueError, SyntaxError), e:
+ msg = e.message or (e.msg + '\n' + e.text)
+ raise osv.except_osv(_('Error!'),_("The domain for the definition %s seems incorrect, please check it.\n\n%s" % (definition.name, msg)))
+ return True
+
+ def create(self, cr, uid, vals, context=None):
+ res_id = super(gamification_goal_definition, self).create(cr, uid, vals, context=context)
+ if vals.get('computation_mode') in ('count', 'sum'):
+ self._check_domain_validity(cr, uid, [res_id], context=context)
+
+ return res_id
+
+ def write(self, cr, uid, ids, vals, context=None):
+ res = super(gamification_goal_definition, self).write(cr, uid, ids, vals, context=context)
+ if vals.get('computation_mode', 'count') in ('count', 'sum') and (vals.get('domain') or vals.get('model_id')):
+ self._check_domain_validity(cr, uid, ids, context=context)
+
+ return res
class gamification_goal(osv.Model):
diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py
index a2bb213cbf6..e24d74e0625 100644
--- a/openerp/osv/fields.py
+++ b/openerp/osv/fields.py
@@ -1267,7 +1267,7 @@ class function(_column):
if values and not multi and name in values[0]:
result = {v['id']: v[name] for v in values}
elif values and multi and all(n in values[0] for n in name):
- result = {v['id']: dict({n: v[n]} for n in name) for v in values}
+ result = {v['id']: dict((n, v[n]) for n in name) for v in values}
else:
result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
if multi: