diff options
| author | Raphael Collet <rco@openerp.com> | 2012-01-24 16:00:53 +0100 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2012-01-24 16:00:53 +0100 |
| commit | f8d582e029f99e7ffb4fcd15ded03d07f4e007d1 (patch) | |
| tree | 36f4dfc152a9a43c01989793e08b313a325a563f | |
| parent | 846c19bf88a592981168d37fc8c18e8177d986d5 (diff) | |
| parent | 8a5335988997b3dced72f005812359173d6fef3c (diff) | |
[MERGE] lp:914264 (survey: fix view when answering a survey)
bzr revid: rco@openerp.com-20120124150053-9t8gi0hhcsyxp0jv
| -rw-r--r-- | addons/survey/wizard/survey_selection.py | 16 | ||||
| -rw-r--r-- | addons/survey/wizard/survey_selection.xml | 3 |
2 files changed, 16 insertions, 3 deletions
diff --git a/addons/survey/wizard/survey_selection.py b/addons/survey/wizard/survey_selection.py index a1fd05cf78a..279571f4f95 100644 --- a/addons/survey/wizard/survey_selection.py +++ b/addons/survey/wizard/survey_selection.py @@ -22,12 +22,13 @@ from osv import osv from osv import fields from tools.translate import _ +from lxml import etree class survey_name_wiz(osv.osv_memory): _name = 'survey.name.wiz' _columns = { - 'survey_id': fields.many2one('survey', 'Survey', required=True, ondelete='cascade'), + 'survey_id': fields.many2one('survey', 'Survey', required=True, ondelete='cascade', domain= [('state', '=', 'open')]), 'page_no': fields.integer('Page Number'), 'note': fields.text("Description"), 'page': fields.char('Page Position',size = 12), @@ -44,6 +45,19 @@ class survey_name_wiz(osv.osv_memory): 'store_ans': '{}' #Setting the default pattern as '{}' as the field is of type text. The field always gets the value in dict format } + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + res = super(survey_name_wiz, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) + if uid != 1: + survey_obj = self.pool.get('survey') + line_ids = survey_obj.search(cr, uid, [('invited_user_ids','in',uid)], context=context) + domain = str([('id', 'in', line_ids)]) + doc = etree.XML(res['arch']) + nodes = doc.xpath("//field[@name='survey_id']") + for node in nodes: + node.set('domain', domain) + res['arch'] = etree.tostring(doc) + return res + def action_next(self, cr, uid, ids, context=None): """ Start the survey, Increment in started survey field but if set the max_response_limit of diff --git a/addons/survey/wizard/survey_selection.xml b/addons/survey/wizard/survey_selection.xml index 144525979dd..a72566f7888 100644 --- a/addons/survey/wizard/survey_selection.xml +++ b/addons/survey/wizard/survey_selection.xml @@ -15,8 +15,7 @@ <separator colspan="4" string="Select Survey" /> <newline /> <field name="survey_id" colspan="4" - on_change="on_change_survey(survey_id)" width="250" - domain="[('state','=','open')]"/> + on_change="on_change_survey(survey_id)" width="250"/> <group col="1" colspan="4" attrs="{'readonly': [('survey_id','=',False)]}"> <separator colspan="4" string="Survey Details" /> |
