- """
- If response is available then print this response otherwise print survey form(print template of the survey).
-
- @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 ids: List of Survey IDs
- @param context: A standard dictionary for contextual values
- @return: Dictionary value for print survey form.
- """
- if context is None:
- context = {}
- record = self.browse(cr, uid, ids, context=context)
- record = record and record[0]
- context.update({'survey_id': record.survey.id, 'response_id': [record.response], 'response_no': 0, })
- value = self.pool.get("survey").action_print_survey(cr, uid, ids, context=context)
- return value
+ """ If response is available then print this response otherwise print survey form (print template of the survey) """
+ context = dict(context or {})
+ applicant = self.browse(cr, uid, ids, context=context)[0]
+ survey_obj = self.pool.get('survey.survey')
+ response_obj = self.pool.get('survey.user_input')
+ if not applicant.response_id:
+ return survey_obj.action_print_survey(cr, uid, [applicant.survey.id], context=context)
+ else:
+ response = response_obj.browse(cr, uid, applicant.response_id.id, context=context)
+ context.update({'survey_token': response.token})
+ return survey_obj.action_print_survey(cr, uid, [applicant.survey.id], context=context)
+
+ def action_get_attachment_tree_view(self, cr, uid, ids, context=None):
+ model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'action_attachment')
+ action = self.pool.get(model).read(cr, uid, action_id, context=context)
+ action['context'] = {'default_res_model': self._name, 'default_res_id': ids[0]}
+ action['domain'] = str(['&', ('res_model', '=', self._name), ('res_id', 'in', ids)])
+ return action
+
+ def message_get_reply_to(self, cr, uid, ids, context=None):
+ """ Override to get the reply_to of the parent project. """
+ applicants = self.browse(cr, SUPERUSER_ID, ids, context=context)
+ job_ids = set([applicant.job_id.id for applicant in applicants if applicant.job_id])
+ aliases = self.pool['project.project'].message_get_reply_to(cr, uid, list(job_ids), context=context)
+ return dict((applicant.id, aliases.get(applicant.job_id and applicant.job_id.id or 0, False)) for applicant in applicants)