Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Trying to send mail to myself in localhost in create - But it Fails every time [Closed]

By
Mostafa Mohamed Abdelmonam Abdo
on 12/9/15, 9:56 AM 308 views

The Question has been closed

by
Ermin Trevisan
on 12/10/2015 08:38:30

Hi there.


i'm trying to send mail to myself in localhost when an invoice has been created but everytime it fails


the maill created successfully and recorded in the database and every thing is fine but why i can't get the mail in my inbox ?


could i have some help here


Here is my code : 

@api.model

@api.returns('self', lambda value: value.id)

def create(self, vals):

invoice = super(exppen_invoice, self).create(vals)

for res in invoice:

body = """

<html>

<head>

<title>Inform of Invoice Creation</title>

</head>

<body>

<h1>Invoice Has been created</h1>

<p><strong>Dears</strong>

<br/>

There is an invoice has been created in

""" + str(res.date_invoice)

body += """;&amp with code ;&amp""" + str(res.bodes)

body += """<br/>and you can find this invoice<a href="/web#id=""" + str(res.id)

body += """&view_type=form&model=account.invoice&action=278>;&amp Here ;&amp</a>

<br/>

<strong>Thanks</strong>

</body>

</html>"""

mail_msg_gets = {

"type": "notification",

'email_from': "LiveConnect System <apps@net2do.com>",

'reply_to': "LiveConnect <support@net2do.com>",

"author_id": 1,

'partner_ids': [(6, 0, [res.partner_id.id])],

'model': 'account.invoice',

'res_id': self.id,

'record_name': 'Created Invoices',

'body': body,

}

mail_message_id = self.env['mail.message'].create(mail_msg_gets)

mail_mail_gets = {

"mail_message_id": mail_message_id.id,

'subject': 'Created Invoices',

'notification': True,

'auto_delete': False,

'model': 'account.invoice',

'res_id': self.id,

"state": 'sent',

'email_to': res.partner_id.email,

'body_html': body,

}

print("mail_mail_vals : ",mail_mail_gets)

mail_mail_id = self.env['mail.mail'].create(mail_mail_gets)

self.env['mail.mail'].send([mail_mail_id])

return invoice

Can you send mails from the backend UI? Any log entries?

Ermin Trevisan
on 12/9/15, 10:42 AM

did you checked the e-mail queue and outgoing e-mail status?

Baiju
on 12/9/15, 10:44 AM

it's not working for me as well, I need to add a different/separte email to get the mail to the smtp on localhost

Peter Niederlag
on 12/9/15, 1:07 PM

Why is it so hard to provide the necessary information in order to get help? Do we have a crystal ball to look into your system????

Ermin Trevisan
on 12/10/15, 2:12 AM

i don't know what is the configs needed but i didn't do any conf at all? is there is an configs that i should add in order to get it work ?

Mostafa Mohamed Abdelmonam Abdo
on 12/10/15, 3:07 AM
0

Ermin Trevisan

--Ermin Trevisan--
3546
| 6 3 7
Walchwil, Switzerland
--Ermin Trevisan--


Ermin Trevisan
On 12/10/15, 8:37 AM

First study how to set up the email system properly. Then try to send an email from the user interface. If it works, try your code again. If you still have errors, post your question with all necessary details, especially with the corresponding log entries.

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/9/15, 9:56 AM
Seen: 308 times
Last updated: 12/10/15, 8:38 AM