[ADD] survey_extra_fields : file question type
This commit is contained in:
65
survey_extra_fields/views/survey_templates.xml
Normal file
65
survey_extra_fields/views/survey_templates.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Extend question_container (form view during survey filling) -->
|
||||
<template
|
||||
id="question_container_inh_type_file"
|
||||
inherit_id="survey.question_container"
|
||||
>
|
||||
<xpath expr="//t[@t-call='survey.question_matrix']/.." position="after">
|
||||
<t t-if="question.question_type == 'file'">
|
||||
<t t-call="survey_extra_fields.question_file"/>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="question_file" name="Question: File">
|
||||
<div class="o_survey_comment_container p-0">
|
||||
<t t-if="answer_lines and answer_lines[0].value_file_fname">
|
||||
<p><t t-out="answer_lines[0].value_file_fname"/></p>
|
||||
</t>
|
||||
<t t-if="not survey_form_readonly">
|
||||
<input
|
||||
type="file"
|
||||
class="o_survey_question_file"
|
||||
t-att-name="question.id"
|
||||
t-att-data-question-type="question.question_type"
|
||||
/>
|
||||
</t>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Extend print/review page to show file answers -->
|
||||
<template
|
||||
id="survey_page_print_inh_type_file"
|
||||
inherit_id="survey.survey_page_print"
|
||||
>
|
||||
<xpath expr="//div[hasclass('o_survey_question_error')]" position="before">
|
||||
<t t-if="question.question_type == 'file'">
|
||||
<t t-if="answer_lines">
|
||||
<t t-set="answer_line" t-value="answer_lines[0]"/>
|
||||
<t t-if="answer_line.skipped">
|
||||
<div class="row g-0">
|
||||
<div class="col-12 col-md-6 col-lg-4 rounded ps-4 o_survey_question_skipped">
|
||||
<input type="text"
|
||||
class="form-control fst-italic o_survey_question_file bg-transparent rounded-0 p-0"
|
||||
value="Skipped"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-elif="answer_line.value_file_fname">
|
||||
<div class="row g-0">
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<a t-attf-href="/survey/file/#{survey.access_token}/#{answer.access_token}/#{answer_line.id}"
|
||||
target="_blank">
|
||||
<i class="fa fa-download me-1"/><t t-out="answer_line.value_file_fname"/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
17
survey_extra_fields/views/survey_user_views.xml
Normal file
17
survey_extra_fields/views/survey_user_views.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="survey_user_input_line_view_form_inh" model="ir.ui.view">
|
||||
<field name="name">survey.user_input.line.view.form.inherit.extra_fields</field>
|
||||
<field name="model">survey.user_input.line</field>
|
||||
<field name="inherit_id" ref="survey.survey_user_input_line_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='suggested_answer_id']" position="after">
|
||||
<field name="value_file" filename="value_file_fname" colspan="2"
|
||||
attrs="{'invisible': [('answer_type', '!=', 'file')]}"/>
|
||||
<field name="value_file_fname" invisible="1"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user