[FIX] gamification: badge auth for badge no error

To avoid exception:
  TypeError: Mixing apples and oranges: gamification.badge() - gamification.badge.user(1,)

when rule_auth of a badge is set to `having`.

opw-1945440
closes #31436
closes #31595

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Suganthi Karunanithi
2019-03-06 18:00:53 +00:00
committed by Nicolas Lempereur
parent a8465d5235
commit eb62cd2c2b
+1 -1
View File
@@ -236,7 +236,7 @@ class GamificationBadge(models.Model):
elif self.rule_auth == 'users' and self.env.user not in self.rule_auth_user_ids:
return self.USER_NOT_VIP
elif self.rule_auth == 'having':
all_user_badges = self.env['gamification.badge.user'].search([('user_id', '=', self.env.uid)])
all_user_badges = self.env['gamification.badge.user'].search([('user_id', '=', self.env.uid)]).mapped('badge_id')
if self.rule_auth_badge_ids - all_user_badges:
return self.BADGE_REQUIRED