[IMP] Survey: Stat button + ability to clean test answers

======
purpose
======

- Allow user directly see the Answers of the Survey from Survey Form view.
- Allow user to Delete all the test answers from Survey Card.

==========
specification
==========

- Add a stat button called "Answers" in the form view of survey with the counter = number of people who have filled it up.
It shows the backend answers because the action button "view results" will show the front end report.
When clicking on it, a group-by Partner will be set.

- On the survey form, add  "Clean test answers" in the action menu
This commit is contained in:
Kinjal Mehta
2016-06-03 11:50:45 +02:00
committed by Yannick Tivisse
parent ed12bfd775
commit c3e425efd2
2 changed files with 40 additions and 5 deletions
+8 -2
View File
@@ -486,8 +486,14 @@ class survey_survey(osv.Model):
'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url'] + "/phantom"
}
def action_survey_user_input(self, cr, uid, ids, context=None):
action_rec = self.pool['ir.model.data'].xmlid_to_object(cr, uid, 'survey.action_survey_user_input', context=context)
action = action_rec.read()[0]
ctx = dict(context)
ctx.update({'search_default_survey_id': ids[0],
'search_default_completed': 1})
action['context'] = ctx
return action
class survey_page(osv.Model):
'''A page for a survey.
+32 -3
View File
@@ -11,7 +11,7 @@
<field name="survey_id"/>
<field name="email"/>
<field name="partner_id"/>
<filter string="Completed" domain="[('state', '=', 'done')]"/>
<filter name="completed" string="Completed" domain="[('state', '=', 'done')]"/>
<filter string="Partially completed" domain="[('state', '=', 'skip')]"/>
<filter string="New" domain="[('state', '=', 'new')]"/>
<filter string="Test" domain="[('state','=', 'test')]"/>
@@ -125,10 +125,16 @@
<field name="stage_id" widget="statusbar" clickable="True" />
</header>
<sheet>
<div class="oe_button_box" name="button_box" attrs="{'invisible': [('is_closed', '=', False)]}">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive" attrs="{'invisible': [('is_closed', '=', False)]}">
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
</button>
<button name="action_survey_user_input"
type="object"
class="oe_stat_button"
icon="fa-pencil-square-o">
<field string="Answers" name="tot_comp_survey" widget="statinfo"/>
</button>
</div>
<div class="oe_title" style="width: 100%;">
<label for="title" class="oe_edit_only"/>
@@ -608,6 +614,29 @@
</field>
</record>
<record id="survey_action_server_clean_test_answers" model="ir.actions.server">
<field name="name">Clean test answers</field>
<field name="condition">True</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_survey_survey" />
<field name="state">code</field>
<field name="code">
if context.get('active_ids'):
test_answers = self.pool['survey.user_input'].search(cr, uid, [('survey_id', 'in', context['active_ids']), ('test_entry', '=', 'True')], context=context)
self.pool['survey.user_input'].unlink(cr, uid, test_answers, context=context)
</field>
</record>
<record id="survey_values_action_clean_test_answers" model="ir.values">
<field name="name">Survey clean test answers</field>
<field name="action_id" ref="survey_action_server_clean_test_answers" />
<field name="value" eval="'ir.actions.server,' + str(ref('survey_action_server_clean_test_answers'))"/>
<field name="key">action</field>
<field name="model_id" ref="model_survey_survey" />
<field name="model">survey.survey</field>
<field name="key2">client_action_multi</field>
</record>
<!-- MENU ELEMENTS -->
<!-- Left menu categories-->