← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~therp-nl/ocb-addons/7.0-lp1244584-survey_test into lp:ocb-addons

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/ocb-addons/7.0-lp1244584-survey_test into lp:ocb-addons.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1103072 in OpenERP Community Backports (Addons): "Survey Invitations - invited user can't answer survey"
  https://bugs.launchpad.net/ocb-addons/+bug/1103072

For more details, see:
https://code.launchpad.net/~therp-nl/ocb-addons/7.0-lp1244584-survey_test/+merge/192679

Providing double protection: prevent the risk of referencing an unassigned variable. Also passing the context from the test. Either of those make the test run.

-- 
https://code.launchpad.net/~therp-nl/ocb-addons/7.0-lp1244584-survey_test/+merge/192679
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~therp-nl/ocb-addons/7.0-lp1244584-survey_test into lp:ocb-addons.
=== modified file 'survey/test/draft2open2close_survey.yml'
--- survey/test/draft2open2close_survey.yml	2011-12-20 16:03:42 +0000
+++ survey/test/draft2open2close_survey.yml	2013-10-25 11:17:52 +0000
@@ -82,7 +82,7 @@
     context = {'active_model':'survey', 'active_id': ref('survey_Initial_partner_feedback'), 'active_ids': [ref('survey_Initial_partner_feedback')]}
     values = self.default_get(cr, uid, ['mail_from', 'mail_subject', 'send_mail_existing', 'mail_subject_existing', 'mail', 'partner_ids', 'send_mail'], context)
     values['mail_from'] = 'Surveyor'
-    new_id = self.create(cr, uid, values)
+    new_id = self.create(cr, uid, values, context)
     self.action_send(cr, uid, [new_id], context)
 -
   I set the value in "Total start survey" field.

=== modified file 'survey/wizard/survey_send_invitation.py'
--- survey/wizard/survey_send_invitation.py	2013-09-03 14:49:15 +0000
+++ survey/wizard/survey_send_invitation.py	2013-10-25 11:17:52 +0000
@@ -60,6 +60,7 @@
         survey_obj = self.pool.get('survey')
         msg = ""
         name = ""
+        survey_id = 0
         for sur in survey_obj.browse(cr, uid, context.get('active_ids', []), context=context):
             name += "\n --> " + sur.title + "\n"
             if sur.state != 'open':
@@ -67,6 +68,7 @@
             data['mail_subject'] = _("Invitation for %s") % (sur.title)
             data['mail_subject_existing'] = _("Invitation for %s") % (sur.title)
             data['mail_from'] = sur.responsible_id.email
+            survey_id = sur.id
         if msg:
             raise osv.except_osv(_('Warning!'), _('The following surveys are not in open state: %s') % msg)
         data['mail'] = _('''
@@ -82,7 +84,7 @@
             self.pool.get('ir.config_parameter').get_param(
                 cr, uid, 'web.base.url', default='http://localhost:8069',
                 context=context)
-                + '#id=%d&view_type=form&model=survey' % sur.id)
+                + '#id=%d&view_type=form&model=survey' % survey_id)
         return data
 
     def create_report(self, cr, uid, res_ids, report_name=False, file_name=False):


Follow ups