[FIX] (website_)hr_recruitment: correct version of
authorRichard Mathot <rim@openerp.com>
Mon, 20 Oct 2014 15:35:33 +0000 (17:35 +0200)
committerRichard Mathot <rim@openerp.com>
Mon, 20 Oct 2014 15:35:33 +0000 (17:35 +0200)
659db669aae1ae58f2b416e3681b66269ed7521d

addons/hr_recruitment/hr_recruitment.py
addons/website_hr_recruitment/controllers/main.py

index fc85786..a265965 100644 (file)
@@ -422,13 +422,6 @@ class hr_applicant(osv.Model):
                 cr, uid, [applicant.job_id.id],
                 body=_('New application from %s') % name,
                 subtype="hr_recruitment.mt_job_applicant_new", context=context)
-            self.message_post(
-                cr, uid, [applicant.id],
-                body = _("%s's Application \n From: %s \n\n %s \n") % (name, vals.get('email_from') or "", vals.get('description',"") or ""),
-                attachments = context.get('attachments'),
-                content_subtype = 'plaintext',
-                subtype = "hr_recruitment.mt_applicant_hired",
-                context = context)
         return obj_id
 
     def write(self, cr, uid, ids, vals, context=None):
index 2f5c20b..45af62d 100644 (file)
@@ -117,9 +117,14 @@ class website_hr_recruitment(http.Controller):
         # Retro-compatibility for saas-3. "phone" field should be replace by "partner_phone" in the template in trunk.
         value['partner_phone'] = post.pop('phone', False)
 
-        attachment = []
+        applicant = env['hr.applicant'].create(value)
         if post['ufile']:
-            attachment.append((post['ufile'].filename, post['ufile'].read()))
-        env['hr.applicant'].with_context(attachments = attachment).create(value)
+            name = applicant.partner_name if applicant.partner_name else applicant.name
+            applicant.message_post(
+                body = _("%s's Application \n From: %s \n\n %s \n") % (name, applicant.email_from or "", applicant.description or ""),
+                attachments = [(post['ufile'].filename, post['ufile'].read())],
+                content_subtype = 'plaintext',
+                subtype = "hr_recruitment.mt_applicant_hired")
+
         return request.render("website_hr_recruitment.thankyou", {})