Skip to Content
Menu
This question has been flagged
3 Replies
1607 Views

Is it possible to send an email to an external address using 'Automation Rules'? I want to send an email to sales@mydomain.com when a website order is placed. 

I am running Odoo17 Enterprise on premise.

Avatar
Discard
Best Answer

Hello Labtree ltd,

Here are the steps to Send an Email Using Automation Rules:

  1. Go to Automation Rules:
    • Navigate to Settings > Technical > Automation > Automated Actions.
  2. Create a New Automated Action:
    • Click Create to add a new automation rule.
  3. Define the Trigger:
    • Model: Set the model to Sale Order (since you're working with website orders).
    • Trigger Condition: Choose On Creation or On Update (depending on when you want the email to be sent).
    • Filter: Add a domain filter to check if the sale order is from the website, using the website_id field. The domain might look something like:
      website_id field. 
      The domain might look something like: [('website_id', '!=', False)]
      {In Odoo, every time an order is created from the website, it has a website linked to the order. You can also use teams to apply the domain.}
  4. Add Server Action:
    • In the Action to Do dropdown, choose Send Email.
    • In the Email Template field, you can create or select an email template. This template will define the content of the email.
      [ I have added the steps with screenshot at the end, how to create an email template ]
  5. Save the Automation Rule:
    • Once you've configured everything, save the rule.


Here are the steps to Create an Email Template with Dynamic Sales Order Information:

  1. Navigate to Email Templates:
    • Go to Settings > Technical > Email > Templates.
  2. Create a New Email Template:
    • Click on the Create button to start a new template.
  3. Basic Template Settings:
    • Name: Give your template a meaningful name, such as "Sales Order Notification for Website Orders".
    • Model: Select Sale Order from the model dropdown. This will link the template to the sale order data.
    • To (Email): Enter the email where you want the email to be sent (e.g., sales@mydomain.com).
  4. Subject:
    • You can make the subject dynamic by using placeholders to include details like the sale order name. 
      For example: New Sale Order {{ object.name }} from Website
  5. Email Body (HTML):
    • In the body of the email, use Odoo's templating language (Jinja2) to insert dynamic fields from the Sale Order model.
  6. Optional: Attach the Sale Order PDF:
    • Scroll down to the Advanced Settings section.
    • In the Optional Report to Print field, select Sale Order / Quotation to attach the PDF version of the sales order to the email.
  7. Save the Template:
    • Once you have configured the template, click Save.


Let me know, if it helps.

Avatar
Discard
Author Best Answer

Thanks to both of you for the information. I have now got this working. I cannot click on the upvotes or ticks as I don't have enough Karma? :/

Avatar
Discard

You're welcome! I'm glad to hear it's working now. No worries about the upvotes or ticks, I appreciate the feedback!
Feel free to reach out if you need further assistance in the future. :)

Best Answer

Hi Labtree Ltd :)
yeah sure. You can get into the developer or debug mode and then access the "automated actions". There are countless good tutorials on YouTube and also here in the forum for several versions of Odoo. I try to sum some things up for you:

  1. You have to have this module installed:  base_automation
  2. Then you can enter the developer or debug mode. Here is the documentation.
  3. Then you go to: Settings -> Technical -> Automation -> Automated Actions
  4. Then you can add a new action

These actions work based on certain triggers, like creating data like a contact or changing something of some data like setting a delivery order to "done". 

If you google "Odoo automated action e-mail" you should find said tutorials.

For your case and since I have a similar automated action in my Odoo 14, here some infos for your to solve your problem: 

  • Set the model to "Sales Order"
  • Set the trigger to "On Update"
  • As Trigger Fields choose "Status (sale.order)"
  • On Before Update Domain you have to choose nothing
  • On Apply I use ["&",["state","=","sent"],["team_id","=","Website"]]. You can directly copy that into the black code editor and of cause adjust it, if you need to.
  • Set Action To Do to "Send Email"
  • For Email Template you have can go to the mail template "Sales Order: Confirmation Mail", copy that, adjust it and then choose your copied template for you automated action. 

I hope, this helps you and saves you some time.

Avatar
Discard
Related Posts Replies Views Activity
0
Feb 25
481
1
Oct 24
1160
1
Sep 24
417
2
Jun 23
1843
0
Jul 23
1014