feat: add is_disc_test flag to surveys and restrict DISC validation logic to relevant surveys
This commit is contained in:
parent
50110aec63
commit
7894951f83
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
.DS_Store
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
@ -14,6 +14,7 @@
|
||||
'depends': ['survey'],
|
||||
'data': [
|
||||
'data/survey_data.xml',
|
||||
'views/survey_survey_views.xml',
|
||||
'views/survey_user_input_views.xml',
|
||||
'views/survey_templates.xml',
|
||||
'report/survey_disc_report.xml',
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
<field name="scoring_type">no_scoring</field>
|
||||
<field name="questions_layout">one_page</field>
|
||||
<field name="is_attempts_limited" eval="False"/>
|
||||
<field name="is_disc_test" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="question_disc_1" model="survey.question">
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import survey_survey
|
||||
from . import survey_question_answer
|
||||
from . import survey_user_input
|
||||
|
||||
7
models/survey_survey.py
Normal file
7
models/survey_survey.py
Normal file
@ -0,0 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields, models
|
||||
|
||||
class SurveySurvey(models.Model):
|
||||
_inherit = 'survey.survey'
|
||||
|
||||
is_disc_test = fields.Boolean("Is DISC Test", default=False)
|
||||
@ -29,6 +29,8 @@ class SurveyUserInput(models.Model):
|
||||
def _mark_done(self):
|
||||
""" Strictly enforce DISC validation: Exactly 1 P and 1 K per set. """
|
||||
for rec in self:
|
||||
if not rec.survey_id.is_disc_test:
|
||||
continue
|
||||
# Group lines by question
|
||||
lines_by_question = {}
|
||||
for line in rec.user_input_line_ids:
|
||||
@ -56,6 +58,12 @@ class SurveyUserInput(models.Model):
|
||||
@api.depends('user_input_line_ids', 'user_input_line_ids.suggested_answer_id')
|
||||
def _compute_disc_scores(self):
|
||||
for rec in self:
|
||||
if not rec.survey_id.is_disc_test:
|
||||
rec.p_d = rec.p_i = rec.p_s = rec.p_c = rec.p_star = 0
|
||||
rec.k_d = rec.k_i = rec.k_s = rec.k_c = rec.k_star = 0
|
||||
rec.c_d = rec.c_i = rec.c_s = rec.c_c = 0
|
||||
rec.disc_profile = False
|
||||
continue
|
||||
# Initialize counts
|
||||
counts = {
|
||||
'p': {'D': 0, 'I': 0, 'S': 0, 'C': 0, '*': 0},
|
||||
|
||||
13
views/survey_survey_views.xml
Normal file
13
views/survey_survey_views.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="survey_survey_view_form_inherit_disc" model="ir.ui.view">
|
||||
<field name="name">survey.survey.view.form.inherit.disc</field>
|
||||
<field name="model">survey.survey</field>
|
||||
<field name="inherit_id" ref="survey.survey_survey_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='scoring_type']" position="after">
|
||||
<field name="is_disc_test"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue
Block a user