diff options
| author | Thibault Delavallée <tde@odoo.com> | 2020-04-03 09:58:57 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-04-03 12:59:29 +0000 |
| commit | 6cf824933f36cd8111ec61a2bb2da5bb99a2ec6a (patch) | |
| tree | 7e98edf09cbf0dd153a0d58d4e335dcd101ed89b /addons/survey/models | |
| parent | bea9bc3d6c51bfc1c4eaad2378caba83b7a5142a (diff) | |
[IMP] survey: cascade archive of a survey to its badge
Purpose of this commit is to synchronize active status of certifications to
their badges. When archiving or activating a certification, its badge is also
archived or activated.
Task ID 2170708
Community PR odoo/odoo#46563
Diffstat (limited to 'addons/survey/models')
| -rw-r--r-- | addons/survey/models/survey_survey.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/addons/survey/models/survey_survey.py b/addons/survey/models/survey_survey.py index c08f13339ba..5d8a297363e 100644 --- a/addons/survey/models/survey_survey.py +++ b/addons/survey/models/survey_survey.py @@ -328,6 +328,12 @@ class Survey(models.Model): default = dict(default or {}, title=title) return super(Survey, self).copy_data(default) + def toggle_active(self): + super(Survey, self).toggle_active() + activated = self.filtered(lambda survey: survey.active) + activated.mapped('certification_badge_id').action_unarchive() + (self - activated).mapped('certification_badge_id').action_archive() + # ------------------------------------------------------------ # ANSWER MANAGEMENT # ------------------------------------------------------------ @@ -946,6 +952,7 @@ class Survey(models.Model): # ------------------------------------------------------------ # GAMIFICATION / BADGES # ------------------------------------------------------------ + def _prepare_challenge_category(self): return 'certification' |
