This commit allow gaining a badge at the end of a certification survey if succeeded. The badge can be configured on the survey if the certification mode is activated. The badge is linked directly to the survey and not the challenge, because it makes more sense to configure directly the reward on the survey and not the way to gain this reward. As the way is always the same. Only one badge can be set on the certification survey. Only the name, description, image and badge level can be configured. The rest of badge configuration is automatically set to correspond to the use case. When a badge is configured on a certification survey, the needed challange, goal and challenge line are autogenerated. The badge is available on the user's profile page if he gained it. Once the badge is configured on the survey, he cannot be changed (remove + create new one), only modified (badge attributes edition). The only way to remove the badge is to uncheck 'certification_give_badge'. When removing the badge from the certification survey, all the autogenerated records (at badge creation) are deleted to avoid ghost records (as they have no purpose outside of this context). If the badge is owned by someone, the badge is only archived. If nobody owns the badge, the badge is deleted. Survey users now have the right to create badges but not challenges or goals. All the autogenerated records are handled in sudo, to allow the survey user to configure a badge on their survey. Note : To avoid having to rewrite the complete context in an xpath expression only to display the certification badge on the user's profile page, the default website_published value of the certification badge is defined directly in the survey module even if survey does not depend of website. This attribute will be ignored until website module is installed. Task ID : 1935136 Closes PR #31486
11 lines
291 B
Python
11 lines
291 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models, fields
|
|
|
|
|
|
class Challenge(models.Model):
|
|
_inherit = 'gamification.challenge'
|
|
|
|
category = fields.Selection(selection_add=[('certification', 'Certifications')])
|