[IMP] survey

bzr revid: chm@openerp.com-20130221162259-bta95ohzqs0koyee
This commit is contained in:
Christophe Matthieu
2013-02-21 17:22:59 +01:00
parent 6017af8055
commit 002ac2f596
7 changed files with 18 additions and 58 deletions
-4
View File
@@ -33,7 +33,6 @@ class survey_type(osv.osv):
_description = 'Survey Type'
_columns = {
'name': fields.char("Name", size=128, required=1, translate=True),
'code': fields.char("Code", size=64),
}
survey_type()
@@ -94,11 +93,9 @@ class survey(osv.osv):
help="Set to one if survey is answerable only once"),
'state': fields.selection([('draft', 'Draft'), ('open', 'Open'), ('close', 'Close'), ('cancel', 'Cancelled')], 'Status', required=1),
'sign_in': fields.boolean('User must be sign up'),
'responsible_id': fields.many2one('res.users', 'Responsible', help="User responsible forsurvey"),
'tot_start_survey': fields.function(_get_tot_start_survey, string="Total Started Survey", type="integer"),
'tot_comp_survey': fields.function(_get_tot_comp_survey, string="Total Completed Survey", type="integer"),
'note': fields.text('Description', size=128),
'send_response': fields.boolean('Email Notification on Answer'),
'type': fields.many2one('survey.type', 'Type'),
'color': fields.integer('Color Index'),
'response_ids': fields.one2many('survey.response', 'survey_id', 'Responses', readonly=1),
@@ -108,7 +105,6 @@ class survey(osv.osv):
_defaults = {
'state': "draft",
'sign_in': False,
'send_response': 1,
'date_open': fields.datetime.now,
'token': lambda s, cr, uid, c: uuid.uuid4(),
}
-3
View File
@@ -3,15 +3,12 @@
<data>
<record model="survey.type" id="survey_type1">
<field name="name">Human Resources</field>
<field name="code">Human Resources</field>
</record>
<record model="survey.type" id="survey_type2">
<field name="name">Customer Feeback</field>
<field name="code">Customer Feeback</field>
</record>
<record model="survey.type" id="survey_type3">
<field name="name">Supplier Selection</field>
<field name="code">Supplier Selection</field>
</record>
</data>
</openerp>
-6
View File
@@ -9,7 +9,6 @@
<!-- Initial Partner Feedback Demo data -->
<record model="survey" id="survey_Initial_partner_feedback">
<field name="title">Initial Partner Feedback</field>
<field name="responsible_id" ref="base.user_root"/>
<field name="max_response_limit">20</field>
<field name="type" ref="survey_type2"/>
<field name="state">open</field>
@@ -157,7 +156,6 @@
<!-- Partner Feedback Demo data -->
<record model="survey" id="survey_partner_feedback">
<field name="title">OpenERP Partner Feedback</field>
<field name="responsible_id" ref="base.user_root"/>
<field name="max_response_limit">20</field>
<field name="type" ref="survey_type2"/>
<field name="state">open</field>
@@ -622,7 +620,6 @@
<!-- Partner Feedback Demo data -->
<record model="survey" id="survey_odoo_feedback">
<field name="title">Odoo Feedback</field>
<field name="responsible_id" ref="base.user_demo"/>
<field name="max_response_limit">20</field>
<field name="type" ref="survey_type2"/>
<field name="state">open</field>
@@ -1396,7 +1393,6 @@
<data>
<record id="survey_0" model="survey">
<field eval="&quot;&quot;&quot;OpenERP Feedback&quot;&quot;&quot;" name="title"/>
<field name="responsible_id" ref="base.user_demo"/>
<field name="color">4</field>
<field name="max_response_limit">20</field>
<field name="type" ref="survey_type2"/>
@@ -2247,8 +2243,6 @@
<field name="note">Please take a few minutes to complete this survey on the quality of service we provide. We welcome your feedback and appreciate your honesty. With your help, we hope to strengthen the bond between our clients.</field>
<field name="state">open</field>
<field name="sign_in">0</field>
<field name="responsible_id" ref="base.user_root"/>
<field eval="1" name="send_response"/>
<field name="type" ref="survey_type3"/>
<field name="max_response_limit">20</field>
</record>
+5 -19
View File
@@ -41,18 +41,11 @@
</h1>
</div>
<group>
<group>
<field name="id" invisible="1"/>
<field name="responsible_id" class="oe_inline" attrs="{'readonly':[('state','=',['close','cancel'])]}"/>
<group colspan="4">
<field name="type" attrs="{'readonly':[('state','in',['close','cancel'])]}" class="oe_inline"/>
<field name="sign_in"/>
</group>
<group>
<field name="max_response_limit" attrs="{'readonly':[('state','=','close')]}"/>
<field name="send_response" attrs="{'readonly':[('state','in',['close','cancel'])]}"/>
</group>
<group colspan="4">
<field name="public_url"/>
<field name="public_url" widget="url"/>
</group>
</group>
<field name="page_ids" colspan="4" mode="tree" attrs="{'readonly':[('state','=','close')]}">
@@ -229,7 +222,6 @@
<tree colors="gray:state == 'close'" string="Survey">
<field name="title"/>
<field name="type"/>
<field name="responsible_id"/>
<field name="date_open" string="Open Date"/>
<field name="tot_start_survey" string="Started"/>
<field name="tot_comp_survey" string="Completed"/>
@@ -254,11 +246,8 @@
<filter string="Closed" domain="[('state','=','close')]"/>
<filter string="Canceled" domain="[('state','=','cancel')]"/>
<separator/>
<filter string="My Surveys" domain="[('responsible_id','=',uid)]" help="The surveys I am responsible of"/>
<filter string="Survey to fill in" name="unread_message" domain="['&amp;', ('response_ids.state', 'in', ['new', 'skip']), ('response_ids.partner_id.user_id', '=', uid)]"/>
<field name="responsible_id"/>
<group expand="0" string="Group By...">
<filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'responsible_id'}"/>
<filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type'}"/>
<filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
</group>
@@ -275,7 +264,6 @@
<field name="date_open"/>
<field name="tot_comp_survey"/>
<field name="max_response_limit"/>
<field name="responsible_id"/>
<field name="color"/>
<field name="state"/>
<field name="public_url"/>
@@ -305,9 +293,9 @@
<br/>
<ul>
<li t-if="widget.view.is_action_enabled('edit')"><a name="edit_survey" string="Edit Survey" type="object">Edit Survey</a></li>
<li t-if="widget.view.is_action_enabled('edit')"><a t-att-style="record.state.raw_value != 'open'?'color:#aaaaaa;':''" name="action_survey_sent" type="object">Collect responses</a></li>
<li><a t-att-style="record.state.raw_value !== 'open'?'color:#aaaaaa;':''" name="fill_survey" type="object">Answer Survey</a></li>
<li t-if="widget.view.is_action_enabled('edit')"><a>Analyze responses</a></li>
<li t-if="record.state.raw_value === 'open' and widget.view.is_action_enabled('edit')"><a name="action_survey_sent" type="object">Collect responses</a></li>
<li><a t-if="record.state.raw_value === 'open'" name="fill_survey" type="object">Answer Survey</a></li>
<li t-if="record.tot_comp_survey.raw_value and widget.view.is_action_enabled('edit')"><a>Analyze responses</a></li>
</ul>
</div>
</div>
@@ -1140,7 +1128,6 @@
<field name="arch" type="xml">
<form string="Survey Type">
<field name="name"/>
<field name="code"/>
</form>
</field>
</record>
@@ -1151,7 +1138,6 @@
<field name="arch" type="xml">
<tree string="Survey Type">
<field name="name"/>
<field name="code"/>
</tree>
</field>
</record>
+10 -19
View File
@@ -190,27 +190,18 @@ class survey_question_wiz(osv.osv_memory):
def _survey_complete(self, cr, uid, survey_id, partner_id, sur_name_read, survey_browse, context):
""" list of action to do when the survey is completed
"""
survey_obj = self.pool.get('survey')
sur_response_obj = self.pool.get('survey.response')
# record complete
sur_response_obj.write(cr, uid, [sur_name_read.response], {'state': 'done'})
self.pool.get('survey.response').write(cr, uid, [sur_name_read.response], {'state': 'done'})
# send mail to the responsible
survey_browse = survey_obj.browse(cr, uid, survey_id, context)
responsible_id = survey_browse.responsible_id and survey_browse.responsible_id.id or False
if survey_browse.send_response and responsible_id:
val = {
'type': 'notification',
'author_id': partner_id or None,
'partner_ids': responsible_id and [responsible_id] or None,
'model': 'survey',
'res_id': survey_id,
'record_name': _("Survey N° %s") % survey_id,
'subject': survey_browse.title or None,
'body': _("A survey answer is completed."),
}
self.pool.get('mail.message').create(cr, uid, val, context=context)
val = {
'type': 'notification',
'model': 'survey',
'res_id': survey_id,
'record_name': _("Survey N° %s") % survey_id,
'body': _("New response on this survey."),
}
self.pool.get('survey').message_post(cr, uid, survey_id, context=context, **val)
def _check_access(self, cr, uid, survey_id, context):
# get if the token of the partner or anonymous user is valid
@@ -442,7 +433,7 @@ class survey_question_wiz(osv.osv_memory):
else:
etree.SubElement(xml_footer, 'label', {'string': ""})
etree.SubElement(xml_footer, 'button', {'name': "action_next", 'string': tools.ustr(but_string), 'type': "object", 'context': tools.ustr(context), 'class': "oe_highlight"})
if context.get('ir_actions_act_window_target', None):
if context.get('ir_actions_act_window_target', None) != 'inline':
etree.SubElement(xml_footer, 'label', {'string': "or"})
etree.SubElement(xml_footer, 'button', {'special': "cancel", 'string': "Exit", 'class': "oe_link"})
etree.SubElement(xml_footer, 'label', {'string': tools.ustr(page_number + 1) + "/" + tools.ustr(total_pages), 'class': "oe_survey_title_page oe_right"})
@@ -92,8 +92,8 @@ class survey_mail_compose_message(osv.TransientModel):
# post the message
values = {
'model': 'survey',
'res_id': wizard.res_id or False,
'model': None,
'res_id': None,
'subject': wizard.subject,
'body': wizard.body.replace("__URL__", url),
'parent_id': None,
@@ -5,7 +5,6 @@
<!--Survey send invitation Email template -->
<record id="email_template_survey" model="email.template">
<field name="name">Survey - Send by Email</field>
<field name="email_from">${object.responsible_id and object.responsible_id.company_id and object.responsible_id.company_id.email or object.responsible_id.email or ''}</field>
<field name="subject">${object.title}</field>
<field name="lang">${object.lang}</field>
<field name="model_id" ref="model_survey"/>
@@ -17,10 +16,7 @@
Would you please spent some of your time to fill-in our survey:
<a href="__URL__">${object.title}</a>
</p>
% if object.responsible_id:
<p>Thank you for choosing ${object.responsible_id.company_id.name or 'us'}!</p>
% endif
<br/>
<p>Thank you for choosing us!</p>
</div>
]]></field>
</record>