[IMP] Kanban view improvements 10-first-clicks

bzr revid: rim@openerp.com-20140325085155-c2ik8r09re5yyna5
This commit is contained in:
Richard Mathot (OpenERP)
2014-03-25 09:51:55 +01:00
parent bd0769a518
commit 2c9b2f1b18
2 changed files with 61 additions and 24 deletions
+41 -15
View File
@@ -57,6 +57,16 @@ class survey_survey(osv.Model):
## Function fields ##
def _is_designed(self, cr, uid, ids, name, arg, context=None):
res = dict()
for survey in self.browse(cr, uid, ids, context=context):
if not survey.page_ids or not [page.question_ids
for page in survey.page_ids if page.question_ids]:
res[survey.id] = False
else:
res[survey.id] = True
return res
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 """
@@ -149,6 +159,8 @@ class survey_survey(osv.Model):
'color': fields.integer('Color Index'),
'user_input_ids': fields.one2many('survey.user_input', 'survey_id',
'User responses', readonly=1),
'designed': fields.function(_is_designed, string="Is designed?",
type="boolean"),
'public_url': fields.function(_get_public_url,
string="Public link", type="char"),
'print_url': fields.function(_get_print_url,
@@ -223,13 +235,13 @@ class survey_survey(osv.Model):
self.message_post(cr, uid, ids, body="""<p>Survey cancelled</p>""", context=context)
return super(survey_survey, self).write(cr, uid, ids, vals, context=context)
def copy(self, cr, uid, ids, default=None, context=None):
;
vals = {}
current_rec = self.read(cr, uid, ids, context=context)
current_rec = self.read(cr, uid, id, context=context)
title = _("%s (copy)") % (current_rec.get('title'))
vals['title'] = title
vals['user_input_ids'] = []
return super(survey_survey, self).copy(cr, uid, ids, vals,
return super(survey_survey, self).copy(cr, uid, id, vals,
context=context)
def next_page(self, cr, uid, user_input, page_id, go_back=False, context=None):
@@ -273,18 +285,22 @@ class survey_survey(osv.Model):
# Web client actions
def action_kanban_update_state(self, cr, uid, ids, context=None):
''' Change the state from the kanban ball '''
for survey in self.read(cr, uid, ids, ['state'], context=context):
if survey['state'] == 'draft':
self.write(cr, uid, [survey['id']], {'state': 'open'}, context=context)
elif survey['state'] == 'open':
self.write(cr, uid, [survey['id']], {'state': 'close'}, context=context)
elif survey['state'] == 'close':
self.write(cr, uid, [survey['id']], {'state': 'cancel'}, context=context)
elif survey['state'] == 'cancel':
self.write(cr, uid, [survey['id']], {'state': 'draft'}, context=context)
return {}
# def action_kanban_update_state(self, cr, uid, ids, context=None):
# ''' Change the state from the kanban ball '''
# for survey in self.read(cr, uid, ids, ['state'], context=context):
# if survey['state'] == 'draft':
# self.write(cr, uid, [survey['id']], {'state': 'open'}, context=context)
# elif survey['state'] == 'open':
# self.write(cr, uid, [survey['id']], {'state': 'close'}, context=context)
# elif survey['state'] == 'close':
# self.write(cr, uid, [survey['id']], {'state': 'cancel'}, context=context)
# elif survey['state'] == 'cancel':
# self.write(cr, uid, [survey['id']], {'state': 'draft'}, context=context)
# return {}
def action_kanban_duplicate(self, cr, uid, ids, context=None):
''' Hack in order to provide "duplicate" action to kanban view '''
return self.copy(cr, uid, ids[0], context=None)
def action_start_survey(self, cr, uid, ids, context=None):
''' Open the website page with the survey form '''
@@ -566,6 +582,16 @@ class survey_question(osv.Model):
('constr_number', 'CHECK (constr_minimum_req_ans <= constr_maximum_req_ans)', 'Max number of answers cannot be smaller than min number!')
]
def copy(self, cr, uid, ids, default=None, context=None):
''' This will prevent duplication of user input lines in case of question duplication
(in cascade, this will also allow to duplicate surveys without duplicating bad user input
lines) '''
vals = {}
import pdb; pdb.set_trace()
vals.update({'user_input_line_ids': []})
return super(survey_question, self).copy(cr, uid, ids, vals,
context=context)
def survey_save(self, cr, uid, ids, context=None):
if context is None:
context = {}
+20 -9
View File
@@ -215,7 +215,8 @@
<field name="model">survey.survey</field>
<field name="arch" type="xml">
<kanban default_group_by="stage_id">
<field name="stage_id" invisible="1"/>
<field name="stage_id" />
<field name="designed" />
<field name="title" />
<field name="date_open" />
<field name="tot_sent_survey" />
@@ -236,20 +237,30 @@
<!-- <li><a name="action_print_survey" type="object">Print Survey...</a></li> -->
<!-- <li><a name="%(action_selected_survey_user_input)d" type="action">View Answers...</a></li> -->
<li><a type="edit">Survey Options</a></li>
<li><a type="object" name="action_kanban_duplicate">Duplicate</a></li>
<li t-if="widget.view.is_action_enabled('delete')"><a type="delete">Delete!</a></li>
<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
</ul>
</div>
<div class="oe_kanban_content">
<h4 class="oe_center"><field name="title" /></h4>
<div>
<ul>
<li><a type="edit">Design</a></li>
<li><a>Test</a></li>
<li><a name="action_send_survey" type="object">Send Invitations</a></li>
<li><a name="action_result_survey" type="object">Analyse Answers</a> <span t-if="record.tot_start_survey.raw_value > 0">(<field name="tot_start_survey" />)</span></li>
</ul>
</div>
<div><ul>
<li>
<a type="edit">Design</a>
</li>
<li>
<t t-if="record.designed.raw_value"><a type="object" name="action_test_survey">Test</a></t>
<t t-if="! record.designed.raw_value"><a style="color: #aaaaaa;">Test</a></t>
</li>
<li>
<t t-if="record.designed.raw_value"><a type="object" name="action_send_survey">Send Invitations</a></t>
<t t-if="! record.designed.raw_value"><a style="color: #aaaaaa;">Send Invitations</a></t>
</li>
<li>
<t t-if="record.tot_start_survey.raw_value &gt; 0"><a name="action_result_survey" type="object">Analyse Answers</a> <span t-if="record.tot_start_survey.raw_value &gt; 0">(<field name="tot_start_survey" />)</span></t>
<t t-if="record.tot_start_survey.raw_value &lt;= 0"><a style="color: #aaaaaa;">Analyse Answers</a></t>
</li>
</ul></div>
<!-- <div>
<center><b>
<a t-if="record.visible_to_user.raw_value === true" name="action_start_survey" type="object"><t t-esc="record.public_url.raw_value"/></a>