Repository: OCA/social

Issue:
Unable to send email on new template
module: mail_notification_email_template
version: 8.0

**Steps to reproduce**
- Install Sales module and activate technical settings
  -configure and test one outgoing server
- Create a new template for Quotation sent ( can keep most values the same as per the Discussions example) , although my final goal is to utilize fields from the sales Quotation
- Create a new draft quotation , add new followers (internal users and one customer)
- make sure that followers is part of the Quotation sent sub type (eg they will receive emails)
- Print the quotation

**Current behavior**
- Emails fails most of the time to all followers, although i have had cases where it succeeds in sending to one.
  -remainder of emails is stuck showing failed status.
  Log file shows :
  **odoo attributeerror: 'mail.notification' object has no attribute '_get_access_link'**

**Expected behavior**
-All emails are supposed to go out using the configured template.

(i have had success where i manually configure the to Email field with email addresses, thus the issue is possibly with the formatting of the to(partners) field, which is currently
${object.partner_id.ids|join(',')}

I currently don't have access to my server logs, but will attach clean logs asap. 
Is there any verbose mode i might need to activate?  (there is debugging on the outgoing servers, but it doesn't seem to generate more data)



Discussion:
post the full source code of the template you use

apologies for the delay - i might have discovered a possible work around on the template. will test on my test server and production to be sure.

will give feedback once done (and post the template source)

ok have retested  by adding partner_id.email as a destination, but results is still strange.

still get an error related to the template on the system log :  

http://pastebin.com/rufKEc63

i received a email on the partner side with subject = partner name  ( not the quotation name)
on the user side, i receive an email  with  just " - quotation sent" in the subject line, thus still no reference to the original quotation.

template code follows :
 From

${object.message_id.email_from|safe}
To (Emails)
    ${object.partner_id.email}
To (Partners)

Subject
    ${object.record.name} - Quotation Sent
Body
    <p>Dear ${object.partner_id.firstname},</p>

<p>${object.display_name}</p>

<p>quotation has been sent.</p>

<p>&nbsp;</p>

<p>congrats</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

Please let me know if any other details is needed (or if i am maybe overlooking something)

thx

line 380 in your log looks like the culprit. Put a breakpoint in https://github.com/OCA/social/blob/8.0/mail_notification_email_template/models/mail_notification.py#L68 and check what the value of `link_html` is. It will probably be `None`, caused by the partner having no user connected.

So check if it is true that this works for partners connected to a user, and fails otherwise. Then file a PR doing nothing if `link_html` comes back falsy.

And I advise you to change the password of the email account in use, it's base64 encoded in your log, which basically means you threw it on the street.

Thank you for the update - i am not into the development per say, but will take a look at how debugging works when i get a chance :)

passwords has been changed - thank you for the warning

Closing this for now until more issues will be found


Resolving patch:
diff --git a/mail_notification_email_template/models/mail_notification.py b/mail_notification_email_template/models/mail_notification.py
--- a/mail_notification_email_template/models/mail_notification.py
+++ b/mail_notification_email_template/models/mail_notification.py
@@ -65,5 +65,5 @@ def _compute_record(self):
                 }),
                 this.partner_id
             )
-            for a in etree.HTML(link_html).xpath('//a[@href]'):
+            for a in etree.HTML(link_html or '<html/>').xpath('//a[@href]'):
                 this.record_access_link = a.get('href')


Test patch: