diff options
| author | Richard Mathot (OpenERP) <rim@openerp.com> | 2014-01-21 17:03:54 +0100 |
|---|---|---|
| committer | Richard Mathot (OpenERP) <rim@openerp.com> | 2014-01-21 17:03:54 +0100 |
| commit | bcff9d072b847d9a0a7b75ae71a618ca341f3fae (patch) | |
| tree | 46057a521227585273070cf9ce004b0cde7fdf7d /addons | |
| parent | a6f149d9b392240bd43d2152a3bdcb65e7a01b91 (diff) | |
[IMP] New kanban view for surveys (inspired of mass_mailing campaigns)
JS links need to be checked in the next revision :-)
bzr revid: rim@openerp.com-20140121160354-oc4jd8k2z71chvob
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/survey/__openerp__.py | 2 | ||||
| -rw-r--r-- | addons/survey/static/src/css/survey.css | 4 | ||||
| -rw-r--r-- | addons/survey/survey.py | 15 | ||||
| -rw-r--r-- | addons/survey/views/survey_views.xml | 57 |
4 files changed, 55 insertions, 23 deletions
diff --git a/addons/survey/__openerp__.py b/addons/survey/__openerp__.py index a8880a8e896..eaa94178791 100644 --- a/addons/survey/__openerp__.py +++ b/addons/survey/__openerp__.py @@ -36,7 +36,7 @@ sent mails with personal token for the invitation of the survey. 'summary': 'Create surveys, collect answers and print statistics', 'author': 'OpenERP SA', 'website': 'https://www.openerp.com/apps/survey/', - 'depends': ['email_template', 'mail', 'website'], + 'depends': ['email_template', 'mail', 'website', 'web_kanban_gauge'], 'data': [ 'security/survey_security.xml', 'security/ir.model.access.csv', diff --git a/addons/survey/static/src/css/survey.css b/addons/survey/static/src/css/survey.css index 361fd5493dc..8feb0c7fc9e 100644 --- a/addons/survey/static/src/css/survey.css +++ b/addons/survey/static/src/css/survey.css @@ -6,8 +6,8 @@ } .openerp .oe_kanban_survey { - width: 212px; - min-height: 86px !important; + width: 540px; + min-height: 220px !important; } .openerp .oe_kanban_survey .oe_kanban_survey_list{ width: 100%; diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 177cf16bdea..a9f78d46167 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -56,6 +56,17 @@ class survey_survey(osv.Model): ## Function fields ## + def _get_tot_sent_survey(self, cr, uid, ids, name, arg, context=None): + """ Returns the number of invitations sent for this survey, be they + (partially) completed or not """ + res = dict((id, 0) for id in ids) + sur_res_obj = self.pool.get('survey.user_input') + for id in ids: + res[id] = sur_res_obj.search(cr, uid, # SUPERUSER_ID, + [('survey_id', '=', id), ('type', '=', 'link')], + context=context, count=True) + return res + def _get_tot_start_survey(self, cr, uid, ids, name, arg, context=None): """ Returns the number of started instances of this survey, be they completed or not """ @@ -63,7 +74,7 @@ class survey_survey(osv.Model): sur_res_obj = self.pool.get('survey.user_input') for id in ids: res[id] = sur_res_obj.search(cr, uid, # SUPERUSER_ID, - [('survey_id', '=', id), ('state', '=', 'skip')], + ['&', ('survey_id', '=', id), '|', ('state', '=', 'skip'), ('state', '=', 'done')], context=context, count=True) return res @@ -108,6 +119,8 @@ class survey_survey(osv.Model): oldname="authenticate"), 'users_can_go_back': fields.boolean('Users can go back', help="If checked, users can go back to previous pages."), + 'tot_sent_survey': fields.function(_get_tot_sent_survey, + string="Number of sent surveys", type="integer"), 'tot_start_survey': fields.function(_get_tot_start_survey, string="Number of started surveys", type="integer"), 'tot_comp_survey': fields.function(_get_tot_comp_survey, diff --git a/addons/survey/views/survey_views.xml b/addons/survey/views/survey_views.xml index 70f019af698..b1208ab0b05 100644 --- a/addons/survey/views/survey_views.xml +++ b/addons/survey/views/survey_views.xml @@ -212,18 +212,21 @@ </field> </record> <record model="ir.ui.view" id="view_survey_kanban"> - <field name="name">event.survey.kanban</field> + <field name="name">survey.kanban</field> <field name="model">survey.survey</field> <field name="arch" type="xml"> <kanban> - <field name="title"/> - <field name="date_open"/> - <field name="tot_comp_survey"/> - <field name="user_input_limit"/> - <field name="color"/> - <field name="state"/> - <field name="auth_required"/> - <field name="public_url"/> + <field name="title" /> + <field name="date_open" /> + <field name="tot_sent_survey" /> + <field name="tot_start_survey" /> + <field name="tot_comp_survey" /> + <field name="user_input_limit" /> + <field name="color" /> + <field name="state" /> + <field name="visible_to_user" /> + <field name="auth_required" /> + <field name="public_url" /> <templates> <div t-name="kanban-box" t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_survey oe_kanban_global_click"> <div class="oe_dropdown_toggle oe_dropdown_kanban" t-if="widget.view.is_action_enabled('edit')"> @@ -247,14 +250,31 @@ <a t-if="record.state.raw_value === 'cancel'" title="Cancelled" class="oe_kanban_status_salmon"> </a> </span> <h3 class="oe_kanban_ellipsis"><t t-esc="record.title.raw_value.toString()"></t></h3> - <div><p> - <ul> - <li>Opening: <field name="date_open"/></li> - <li>Closing: <field name="date_close"/></li> - </ul> - </p></div> - <div class="oe_stats_box"><span><field name="tot_start_survey"/></span><br/>started</div> - <div class="oe_stats_box"><span><field name="tot_comp_survey"/></span><br/>completed</div> + <div t-if="record.visible_to_user.raw_value === false"> + <center> + <field name="tot_sent_survey" widget="gauge" style="width:160px; height: 120px;" + options="{'max_field': 'tot_sent_survey'}"/> + <field name="tot_start_survey" widget="gauge" style="width:160px; height: 120px;" + options="{'max_field': 'tot_sent_survey'}"/> + <field name="tot_comp_survey" widget="gauge" style="width:160px; height: 120px;" + options="{'max_field': 'tot_sent_survey'}"/> + </center> + </div> + <div t-if="record.visible_to_user.raw_value === true"> + <center> + <field name="tot_start_survey" widget="gauge" style="width:160px; height: 120px;" + options="{'max_field': 'tot_start_survey'}"/> + <field name="tot_comp_survey" widget="gauge" style="width:160px; height: 120px;" + options="{'max_field': 'tot_start_survey'}"/> + </center> + </div> + <div t-if="record.visible_to_user.raw_value === true"> + <center><b><a t-att-href="record.public_url.raw_value"><t t-esc="record.public_url.raw_value"/></a></b></center> + </div> + <div> + Opening date: <field name="date_open" /><br /> + Closing date: <field name="date_close" /> + </div> </div> </div> </templates> @@ -277,7 +297,6 @@ <field name="res_model">survey.survey</field> <field name="view_type">form</field> <field name="view_mode">kanban,tree,form,calendar</field> - <field name="view_id" ref="view_survey_kanban"></field> <field name="search_view_id" ref="survey_search"/> <field name="help" type="html"> <p class="oe_view_nocontent_create">Click to create a new survey.</p> @@ -562,7 +581,7 @@ <field name="name">Survey User Input lines</field> <field name="res_model">survey.user_input_line</field> <field name="view_mode">tree,form</field> - </record> --> + </record> <!-- ACTIONS --> |
