[FIX] Providing double protection: prevent the risk of referencing an unassigned...
authorChristophe CHAUVET <christophe.chauvet@syleam.fr>
Sat, 2 Nov 2013 08:01:57 +0000 (08:01 +0000)
committerStefan Rijnhart <stefan@therp.nl>
Wed, 2 Jul 2014 17:42:10 +0000 (19:42 +0200)
https://launchpad.net/bugs/1103072

addons/survey/test/draft2open2close_survey.yml
addons/survey/wizard/survey_send_invitation.py

index 926810c..7b314f4 100644 (file)
@@ -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.
index 1b9839c..b2175b4 100644 (file)
@@ -60,6 +60,7 @@ class survey_send_invitation(osv.osv_memory):
         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 @@ class survey_send_invitation(osv.osv_memory):
             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 @@ Thanks,''') % (
             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):