summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Pinckaers <fp@openerp.com>2012-09-10 22:38:12 +0200
committerFabien Pinckaers <fp@openerp.com>2012-09-10 22:38:12 +0200
commitd541c9aa9c04b5d2b8f33a154e46bed261b5beb7 (patch)
treeeb5b5d07542d6c3a8e70525dbbe37c4646e53975
parentf711f7d9a6b3a7778e805efbfc66203e6a94aa8d (diff)
parent40aaf38df17bf815727845246fe8d872e4073325 (diff)
[IMP] survey layouts
bzr revid: fp@openerp.com-20120910203812-9um0kgso8598t6jr
-rw-r--r--addons/survey/__openerp__.py4
-rw-r--r--addons/survey/specification/survey.pngbin83247 -> 67420 bytes
-rw-r--r--addons/survey/specification/survey_page.pngbin70614 -> 50072 bytes
-rw-r--r--addons/survey/specification/survey_question.pngbin91547 -> 56641 bytes
-rw-r--r--addons/survey/specification/survey_response.pngbin75180 -> 56037 bytes
-rw-r--r--addons/survey/static/src/css/survey.css18
-rw-r--r--addons/survey/survey.py22
-rw-r--r--addons/survey/survey_view.xml16
-rw-r--r--addons/survey/wizard/survey_answer.py100
-rw-r--r--addons/survey/wizard/survey_answer.xml5
10 files changed, 91 insertions, 74 deletions
diff --git a/addons/survey/__openerp__.py b/addons/survey/__openerp__.py
index 1470754cb03..40eb3073d61 100644
--- a/addons/survey/__openerp__.py
+++ b/addons/survey/__openerp__.py
@@ -56,10 +56,10 @@ user name and password for the invitation of the survey.
'test/survey_question_type.yml',
'test/survey_report.yml',
],
- 'css': ['static/src/css/survey.css'],
'installable': True,
'auto_install': False,
'certificate' : '001131639736864143245',
- 'images': ['images/survey_answers.jpeg','images/survey_pages.jpeg','images/surveys.jpeg'],
+ 'images': ['images/survey_answers.jpeg','images/survey_pages.jpeg','images/surveys.jpeg'],
+ 'css': ['static/src/css/survey.css','static/css/survey.css'],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/survey/specification/survey.png b/addons/survey/specification/survey.png
index 8cf0f7022c1..52acff391d0 100644
--- a/addons/survey/specification/survey.png
+++ b/addons/survey/specification/survey.png
Binary files differ
diff --git a/addons/survey/specification/survey_page.png b/addons/survey/specification/survey_page.png
index 2f8d19d5dd8..4fceac4b81b 100644
--- a/addons/survey/specification/survey_page.png
+++ b/addons/survey/specification/survey_page.png
Binary files differ
diff --git a/addons/survey/specification/survey_question.png b/addons/survey/specification/survey_question.png
index b939ae2ad47..516606902cb 100644
--- a/addons/survey/specification/survey_question.png
+++ b/addons/survey/specification/survey_question.png
Binary files differ
diff --git a/addons/survey/specification/survey_response.png b/addons/survey/specification/survey_response.png
index 67bc1aa9432..af78bd1977d 100644
--- a/addons/survey/specification/survey_response.png
+++ b/addons/survey/specification/survey_response.png
Binary files differ
diff --git a/addons/survey/static/src/css/survey.css b/addons/survey/static/src/css/survey.css
index c18f584c9ed..7a2174fda8c 100644
--- a/addons/survey/static/src/css/survey.css
+++ b/addons/survey/static/src/css/survey.css
@@ -1,14 +1,6 @@
-.oe_survey_responsible{
- height: auto;
- width: 200px;
- font-size: 14px;
-}
-
-.oe_survey_start_date{
- height: auto;
- width: 200px;
- font-size: 14px;
-}
-.oe_survey_rate{
- font-size: 14px;
+.oe_survey_title {
+ font-weight: bold;
+ font-size: 19px;
+ margin: 8px 0px 8px 0px;
+ color: #5B5B5B;
}
diff --git a/addons/survey/survey.py b/addons/survey/survey.py
index 93bd48be30c..dde3130e9c5 100644
--- a/addons/survey/survey.py
+++ b/addons/survey/survey.py
@@ -145,15 +145,33 @@ class survey(osv.osv):
return report
def fill_survey(self, cr, uid, ids, context=None):
+ sur_obj = self.read(cr, uid, ids,['title'], context=context)
+ for sur in sur_obj:
+ name = sur['title']
+ context.update({'active':False,'survey_id': ids[0]})
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
- 'context': {'survey_id': ids[0]}
+ 'name': name,
+ 'context': context
+ }
+ def test_survey(self, cr, uid, ids, context=None):
+ sur_obj = self.read(cr, uid, ids,['title'], context=context)
+ for sur in sur_obj:
+ name = sur['title']
+ context.update({'active':True,'survey_id': ids[0]})
+ return {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'survey.question.wiz',
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'name': name,
+ 'context': context
}
-
survey()
class survey_history(osv.osv):
diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml
index 8b49b89df65..5b71d70542b 100644
--- a/addons/survey/survey_view.xml
+++ b/addons/survey/survey_view.xml
@@ -26,8 +26,8 @@
</header>
<sheet>
<div class="oe_button_box oe_right">
- <button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel" string="Test Survey" type="action" icon="gtk-new" context="{'active':True,'survey_id': active_id}" attrs="{'invisible':[('id','=',0)]}"/>
- <button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel" string="Answer Survey" type="action" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
+ <button name="test_survey" states="open,draft,close,cancel" string="Test Survey" type="object" icon="gtk-new" context="{'survey_id': active_id}" attrs="{'invisible':[('id','=',0)]}"/>
+ <button name="fill_survey" states="open" string="Answer Survey" type="object" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
</div>
<div class="oe_title">
<label for="title" class="oe_edit_only"/>
@@ -254,13 +254,11 @@
<field name="tot_start_survey" string="Started"/>
<field name="tot_comp_survey" string="Completed"/>
<field name="state"/>
- <button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
- string="Test Survey" type="action" icon="gtk-new"
- context="{'active':True,'survey_id': active_id}"/>
- <button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
- string="Answer Survey" type="action" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
- <button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
- string="Edit Survey" type="action" icon="gtk-edit" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
+ <button name="test_survey" states="open,draft,close,cancel"
+ string="Test Survey" type="object" icon="gtk-new"
+ context="{'survey_id': active_id}"/>
+ <button name="fill_survey" states="open"
+ string="Answer Survey" type="object" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
<button name="action_print_survey" states="open,draft,close,cancel"
string="Print Answer" type="object" icon="gtk-print"/>
</tree>
diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py
index e2216ea8389..7d16b88a4ef 100644
--- a/addons/survey/wizard/survey_answer.py
+++ b/addons/survey/wizard/survey_answer.py
@@ -146,7 +146,21 @@ class survey_question_wiz(osv.osv_memory):
pre_button = True
if flag:
pag_rec = page_obj.browse(cr, uid, p_id, context=context)
- xml_form = etree.Element('form', {'string': tools.ustr(pag_rec.title)})
+ xml_form = etree.Element('form', {'string': tools.ustr(sur_rec.title)})
+ xml_header = etree.SubElement(xml_form, 'header', {'col': '6', 'colspan': '4' ,'class': 'oe_survey_title_height'})
+ xml_header_title = etree.SubElement(xml_header, 'group', {'col': '6', 'colspan': '6'})
+
+ etree.SubElement(xml_header_title, 'label', {'string': tools.ustr(pag_rec.title) ,'colspan': '2' ,'class' : 'oe_survey_title'})
+ xml_header_group = etree.SubElement(xml_header_title, 'group', {'col': '4', 'colspan': '1'})
+ if context.has_key('active') and context.get('active',False) and context.has_key('edit'):
+ etree.SubElement(xml_form, 'separator', {'string' : '','colspan': '4'})
+ context.update({'page_id' : tools.ustr(p_id),'page_number' : sur_name_rec.page_no , 'transfer' : sur_name_read.transfer})
+ xml_group3 = etree.SubElement(xml_form, 'group', {'col': '4', 'colspan': '4'})
+ etree.SubElement(xml_group3, 'button', {'string' :'Add Page','icon': "gtk-new", 'type' :'object','name':"action_new_page", 'context' : tools.ustr(context)})
+ etree.SubElement(xml_group3, 'button', {'string' :'Edit Page','icon': "gtk-edit", 'type' :'object','name':"action_edit_page", 'context' : tools.ustr(context)})
+ etree.SubElement(xml_group3, 'button', {'string' :'Delete Page','icon': "gtk-delete", 'type' :'object','name':"action_delete_page", 'context' : tools.ustr(context)})
+ etree.SubElement(xml_group3, 'button', {'string' :'Add Question','icon': "gtk-new", 'type' :'object','name':"action_new_question", 'context' : tools.ustr(context)})
+
xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'})
if context.has_key('response_id') and context.get('response_id', False) \
and int(context.get('response_id',0)[0]) > 0:
@@ -162,7 +176,7 @@ class survey_question_wiz(osv.osv_memory):
if wiz_id:
fields["wizardid_" + str(wiz_id)] = {'type':'char', 'size' : 255, 'string':"", 'views':{}}
- etree.SubElement(xml_form, 'field', {'invisible':'1','name': "wizardid_" + str(wiz_id),'default':str(lambda *a: 0)})
+ etree.SubElement(xml_form, 'field', {'invisible':'1','name': "wizardid_" + str(wiz_id),'default':str(lambda *a: 0),'modifiers':'{"invisible":true}'})
if pag_rec.note:
xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'})
@@ -353,35 +367,30 @@ class survey_question_wiz(osv.osv_memory):
fields[tools.ustr(que.id) + "_other"] = {'type': 'text', 'string': '', 'views':{}}
etree.SubElement(xml_form, 'separator', {'colspan': '4'})
- xml_group = etree.SubElement(xml_form, 'group', {'col': '6', 'colspan': '4'})
- etree.SubElement(xml_group, 'field', {'name': 'progress_bar_' + tools.ustr(page_number) , 'widget':'progressbar'})
- fields['progress_bar_' + tools.ustr(page_number)] = {'type':'float', 'string':"Progress", 'views':{}}
- etree.SubElement(xml_group, 'label', {'string': tools.ustr(page_number+ 1) + "/" + tools.ustr(total_pages)})
- etree.SubElement(xml_group, 'button', {'icon': "gtk-cancel", 'special': "cancel",'string':"Cancel"})
-
+
+ xml_footer = etree.SubElement(xml_form, 'footer', {'col': '8', 'colspan': '1', 'width':"100%"})
+
if pre_button:
- etree.SubElement(xml_group, 'button', {'colspan':"1",'icon':"gtk-go-back",'name':"action_previous",'string':"Previous",'type':"object"})
+ etree.SubElement(xml_footer, 'label', {'string': ""})
+ etree.SubElement(xml_footer, 'button', {'name':"action_previous",'string':"Previous",'type':"object"})
but_string = "Next"
if int(page_number) + 1 == total_pages:
but_string = "Done"
-
if context.has_key('active') and context.get('active',False) and int(page_number) + 1 == total_pages and context.has_key('response_id') and context.has_key('response_no') and context.get('response_no',0) + 1 == len(context.get('response_id',0)):
- etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'special' : 'cancel','string': tools.ustr("Done") ,'context' : tools.ustr(context)})
+ etree.SubElement(xml_footer, 'label', {'string': ""})
+ etree.SubElement(xml_footer, 'button', {'special' : 'cancel','string': tools.ustr("Done") ,'context' : tools.ustr(context), 'class':"oe_highlight"})
elif context.has_key('active') and context.get('active', False) and int(page_number) + 1 == total_pages and context.has_key('response_id'):
- etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'name':"action_forward_next",'string': tools.ustr("Next Answer") ,'type':"object",'context' : tools.ustr(context)})
+ etree.SubElement(xml_footer, 'label', {'string': ""})
+ etree.SubElement(xml_footer, 'button', {'name':"action_forward_next",'string': tools.ustr("Next Answer") ,'type':"object",'context' : tools.ustr(context), 'class':"oe_highlight"})
elif context.has_key('active') and context.get('active',False) and int(page_number) + 1 == total_pages:
- etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'special': "cancel", 'string' : 'Done', 'context' : tools.ustr(context)})
+ etree.SubElement(xml_footer, 'label', {'string': ""})
+ etree.SubElement(xml_footer, 'button', {'special': "cancel", 'string' : 'Done', 'context' : tools.ustr(context), 'class':"oe_highlight"})
else:
- etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'name':"action_next",'string': tools.ustr(but_string) ,'type':"object",'context' : tools.ustr(context)})
-
- if context.has_key('active') and context.get('active',False) and context.has_key('edit'):
- etree.SubElement(xml_form, 'separator', {'string' : '','colspan': '4'})
- context.update({'page_id' : tools.ustr(p_id),'page_number' : sur_name_rec.page_no , 'transfer' : sur_name_read.transfer})
- xml_group3 = etree.SubElement(xml_form, 'group', {'col': '4', 'colspan': '4'})
- etree.SubElement(xml_group3, 'button', {'string' :'Add Page','icon': "gtk-new", 'type' :'object','name':"action_new_page", 'context' : tools.ustr(context)})
- etree.SubElement(xml_group3, 'button', {'string' :'Edit Page','icon': "gtk-edit", 'type' :'object','name':"action_edit_page", 'context' : tools.ustr(context)})
- etree.SubElement(xml_group3, 'button', {'string' :'Delete Page','icon': "gtk-delete", 'type' :'object','name':"action_delete_page", 'context' : tools.ustr(context)})
- etree.SubElement(xml_group3, 'button', {'string' :'Add Question','icon': "gtk-new", 'type' :'object','name':"action_new_question", 'context' : tools.ustr(context)})
+ 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"})
+ 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"})
root = xml_form.getroottree()
result['arch'] = etree.tostring(root)
@@ -393,27 +402,28 @@ class survey_question_wiz(osv.osv_memory):
# mark the survey request as done; call 'survey_req_done' on its actual model
survey_req_obj = self.pool.get(context.get('active_model'))
- if survey_req_obj and hasattr(survey_req_obj, 'survey_req_done'):
+ if survey_req_obj and hasattr(survey_req_obj, 'survey_req_done'):
survey_req_obj.survey_req_done(cr, uid, context.get('active_ids', []), context=context)
if sur_rec.send_response:
survey_data = survey_obj.browse(cr, uid, survey_id)
response_id = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False))['response']
- context.update({'response_id':response_id})
report = self.create_report(cr, uid, [survey_id], 'report.survey.browse.response', survey_data.title,context)
attachments = {}
- file = open(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")
- file_data = ""
- while 1:
- line = file.readline()
- file_data += line
- if not line:
- break
-
- attachments[survey_data.title + ".pdf"] = file_data
- file.close()
- os.remove(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")
-
+ pdf_filename = addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf"
+ if os.path.exists(pdf_filename):
+ file = open(pdf_filename)
+ file_data = ""
+ while 1:
+ line = file.readline()
+ file_data += line
+ if not line:
+ break
+
+ attachments[survey_data.title + ".pdf"] = file_data
+ file.close()
+ os.remove(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")
+ context.update({'response_id':response_id})
user_email = user_obj.browse(cr, uid, uid, context).email
resp_email = survey_data.responsible_id and survey_data.responsible_id.email or False
@@ -433,10 +443,12 @@ class survey_question_wiz(osv.osv_memory):
self.pool.get('mail.mail').create(cr, uid, vals, context=context)
xml_form = etree.Element('form', {'string': _('Complete Survey Answer')})
+ xml_footer = etree.SubElement(xml_form, 'footer', {'col': '6', 'colspan': '4' ,'class': 'oe_survey_title_height'})
+
etree.SubElement(xml_form, 'separator', {'string': 'Complete Survey', 'colspan': "4"})
etree.SubElement(xml_form, 'label', {'string': 'Thanks for your Answer'})
etree.SubElement(xml_form, 'newline')
- etree.SubElement(xml_form, 'button', {'icon': "gtk-go-forward", 'special':"cancel",'string':"OK",'colspan':"2"})
+ etree.SubElement(xml_footer, 'button', {'special':"cancel",'string':"OK",'colspan':"2",'class':'oe_highlight'})
root = xml_form.getroottree()
result['arch'] = etree.tostring(root)
result['fields'] = {}
@@ -445,7 +457,7 @@ class survey_question_wiz(osv.osv_memory):
def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None):
"""
- If any user give answer of survey then last create report of this answer and if 'Email Notification on Answer' set True in survey then send mail on responsible person of this survey and attach survey answer report in pdf format.
+ If any user give answer of survey then last create report of this answer and if 'E-mail Notification on Answer' set True in survey then send mail on responsible person of this survey and attach survey answer report in pdf format.
"""
if not report_name or not res_ids:
return (False, Exception('Report name and Resources ids are required !!!'))
@@ -473,7 +485,6 @@ class survey_question_wiz(osv.osv_memory):
except Exception,e:
return (False, str(e))
-
return (True, ret_file_name)
def default_get(self, cr, uid, fields_list, context=None):
@@ -490,7 +501,6 @@ class survey_question_wiz(osv.osv_memory):
value[field] = tot_per
response_obj = self.pool.get('survey.response')
surv_name_wiz = self.pool.get('survey.name.wiz')
-
if context.has_key('response_id') and context.get('response_id') and int(context['response_id'][0]) > 0:
data = super(survey_question_wiz, self).default_get(cr, uid, fields_list, context)
response_ans = response_obj.browse(cr, uid, context['response_id'][context['response_no']])
@@ -537,11 +547,11 @@ class survey_question_wiz(osv.osv_memory):
value[field] = ans.answer
else:
+
if not context.has_key('sur_name_id'):
return value
if context.has_key('active') and context.get('active',False):
return value
-
sur_name_read = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False))
ans_list = []
@@ -549,7 +559,6 @@ class survey_question_wiz(osv.osv_memory):
for field in fields_list:
if field in list(val):
value[field] = val[field]
-
return value
def create(self, cr, uid, vals, context=None):
@@ -603,8 +612,9 @@ class survey_question_wiz(osv.osv_memory):
self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
self.pool.get(context.get('object',False)).survey_req_done(cr, uid, [int(context.get('cur_id'))], context)
else:
- self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
- if sur_name_read['store_ans'] and type(sur_name_read['store_ans']) == dict:
+ self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
+ if sur_name_read['store_ans'] and type(safe_eval(sur_name_read['store_ans'])) == dict:
+ sur_name_read['store_ans'] = safe_eval(sur_name_read['store_ans'])
for key,val in sur_name_read['store_ans'].items():
for field in vals:
if field.split('_')[0] == val['question_id']:
diff --git a/addons/survey/wizard/survey_answer.xml b/addons/survey/wizard/survey_answer.xml
index 3460ad41bb3..b02f9fb2be5 100644
--- a/addons/survey/wizard/survey_answer.xml
+++ b/addons/survey/wizard/survey_answer.xml
@@ -5,8 +5,8 @@
<!--
Survey Question Wizard
-->
- <record id="view_survey_question_message" model="ir.ui.view">
- <field name="name">Answer Survey</field>
+ <record id="view_survey_question_message" model="ir.ui.view">
+ <field name="name">Survey Answer</field>
<field name="model">survey.question.wiz</field>
<field name="arch" type="xml">
<form string="Your Messages" version="7.0">
@@ -26,7 +26,6 @@
</record>
<record id="action_view_survey_question_message" model="ir.actions.act_window">
- <field name="name">Answer Survey</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">survey.question.wiz</field>
<field name="view_type">form</field>