diff --git a/addons/crm_profiling/__openerp__.py b/addons/crm_profiling/__openerp__.py index 382fbcb1b28..656f8360f0b 100644 --- a/addons/crm_profiling/__openerp__.py +++ b/addons/crm_profiling/__openerp__.py @@ -39,7 +39,7 @@ It also has been merged with the earlier CRM & SRM segmentation tool because the 'website': 'http://www.openerp.com', 'depends': ['base', 'crm'], 'init_xml': [], - 'update_xml': ['security/ir.model.access.csv', 'wizard/open_questionnaire_view.xml', 'crm_profiling_view.xml'], + 'update_xml': ['security/ir.model.access.csv', 'crm_profiling_view.xml'], 'demo_xml': ['crm_profiling_demo.xml'], 'test': ['test/test_crm_profiling.yml'], 'installable': True, diff --git a/addons/crm_profiling/crm_profiling.py b/addons/crm_profiling/crm_profiling.py index 17cc04bc1d9..59137966da0 100644 --- a/addons/crm_profiling/crm_profiling.py +++ b/addons/crm_profiling/crm_profiling.py @@ -159,19 +159,19 @@ class questionnaire(osv.osv): _name="crm_profiling.questionnaire" _description= "Questionnaire" - def build_form(self, cr, uid, questionnaire_id, context=None): + def build_form(self, cr, uid, data, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param data: Get Data @param context: A standard dictionary for contextual values """ - + query = """ select name, id from crm_profiling_question where id in ( select question from profile_questionnaire_quest_rel where questionnaire = %s)""" - res = cr.execute(query, (questionnaire_id,)) + res = cr.execute(query, (data['form']['questionnaire_name'],)) result = cr.fetchall() quest_fields={} quest_form=''' @@ -180,6 +180,7 @@ class questionnaire(osv.osv): quest_form = quest_form + '' % (oid,) quest_fields['quest_form%d' % (oid,)] = {'string': name, 'type': 'many2one', \ 'relation': 'crm_profiling.answer', 'domain': [('question_id','=',oid)] } + quest_form = quest_form + '''''' return quest_form, quest_fields _columns = { @@ -218,16 +219,16 @@ class partner(osv.osv): @param context: A standard dictionary for contextual values """ temp = [] - for x in context.get('fields'): - if x.startswith("quest_form") and data[x] != 0 : - if data[x] and data[x][0]: - temp.append(data[x][0]) - partner_id = context.get('active_id') + for x in data['form']: + if x.startswith("quest_form") and data['form'][x] != 0 : + temp.append(data['form'][x]) + query = "select answer from partner_question_rel where partner=%s" - cr.execute(query, (partner_id,)) + cr.execute(query, (data['id'],)) for x in cr.fetchall(): temp.append(x[0]) - self.write(cr, uid, [partner_id], {'answers_ids':[[6, 0, temp]]}, context=context) + + self.write(cr, uid, [data['id']], {'answers_ids':[[6, 0, temp]]}, context=context) return {} diff --git a/addons/crm_profiling/crm_profiling_view.xml b/addons/crm_profiling/crm_profiling_view.xml index a54d3d4b0a9..258de2e4e2d 100644 --- a/addons/crm_profiling/crm_profiling_view.xml +++ b/addons/crm_profiling/crm_profiling_view.xml @@ -2,6 +2,13 @@ + + Questionnaires crm_profiling.questionnaire @@ -133,7 +140,7 @@