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.

2

How to trigger an email on project issue changes?

By
Martin
on 11/7/13, 1:08 PM 8,169 views

I like to trigger an email to some users on every change in all project issues (notes logged, email sent or received, state changed, opened, closed, deleted). How can I achieve this? I don't fear hacking in Python or XML, no problem.

7

Olivier Dony (odo)

--Olivier Dony (odo)--
2112
| 7 6 7
--Olivier Dony (odo)--

 

Olivier Dony (odo)
On 11/7/13, 3:07 PM

This is what the follower/notification system in OpenERP 7.0 does.

Notifications in OpenERP 7.0

When you are following an issue, you get an email for new entries added in the history log at the bottom of the issue, depending on the kind of notifications you are following. You can select the kind of notification you want to receive using the checkboxes that are located below the "Follow" button:

image description

Each notification for any of those events will be sent to your Inbox inside OpenERP (in the Messaging/Inbox menu), and you can then control whether those notification should also be sent to your external mailbox in the user preferences. By default you only follow new comments, and they are automatically forwarded to your external mailbox.

image description

You don't need to do any custom development unless you want to change this behavior in any unforeseen ways. Note that users automatically follow new issues if they are followers of the project.

Email Aliases

Additionally, OpenERP v7 provides a convenient "email alias" system, as described here in the release notes. This lets you map a specific email address for each project, as soon as you have configured a global domain redirection. Then any inbound email will create an issue or task in the appropriate project directly.

Let's say you configure the email subdomain "erp.mycompany.com" as a catch-all that redirects all incoming emails to the OpenERP inbound mail script (located in the mail module directory, in mail/static/scripts/mail_gateway.py). This requires an appropriate configuration of your inbound mail system (outside OpenERP), and then a proper configuration of the corresponding OpenERP setting:

image description

The email alias system also works if you have configured manual fetchmail rules instead of a global catchall redirection. Basically whenever any incoming email is routed to OpenERP (through fetchmail rules or the mail_gateway script), the "To" address will be looked up in the aliases mapping, and the fallback routing (such as the one you can configure on a fetchmail rule) will only be applied if no alias matched.

Projects (and other objects like Sales Teams, etc.) will automatically setup appropriate email aliases when you create them. You can change the alias address on the project itself, it's visible on the project form as soon as a catchall domain is configured, or you can manually create and edit aliases in the alias menu (Settings/Technical/Email/Aliases, requires Technical Features access right). Each email alias has an optional set of "Default values" that will be applied to new documents created through this alias - this is actually how the automatic assignment of a project on new issues or task works. The system configures it by default but you can edit the default value to do other things, automatically assign a responsible user, etc.

These concepts may be a bit complicated to understand but they are in fact pretty simple yet extremely flexible and powerful. You can create as many email aliases as you want and dynamically route them to any destination table in the system, with any default value you want.

Technical precision about the setup: a global "catchall" redirection is the most flexible way to setup this system, but it requires technical skills, management access to the company's mail servers, availability of a DNS subdomain that can be assigned to this, etc. This is automatically configured for all users on OpenERP Online, but may not be easy to setup for on-site deployments. When this is not possible you can still benefit from the dynamic email aliases by using fetchmail rules, and you don't necessarily have to setup one external email box to fetch for each alias. Many modern email systems and providers such as GMail support a feature called "plus addressing": if you have an account mycompany@gmail.com, you will also receive emails sent to mycompany+project1@gmail.com, mycompany+foo@gmail.com, etc., without having to configure anything. Then because these emails will be fetched by your OpenERP rules, you can setup email aliases in OpenERP to match the relevant "plus addresses" that you are using. An alias mycompany+project1 would then match all emails sent to mycompany+project1@gmail.com if you have configured a fetchmail rule for GMail account mycompany@gmail.com.

Many thanks for your detailled answer, Olivier! Two problems remain: Firstly, when issues are created by incoming email, they don't have a project assigned. This means, the person who might assign the issue to a project does not get informed and the issue will get unnoticed. Secondly, even when I assign an issue to a project I'm member in and have my email preferences to get all messages, I do not get an email when another user logs a note.

Martin
on 11/7/13, 4:12 PM

Martin, I've added a section about email aliases in my answer, it is a nice way to automatically assign issues to the right project for each incoming email. I hope the explanation is clear, it is a complicated thing to explain, but actually easy and powerful once you understand the concepts.

Olivier Dony (odo)
on 11/8/13, 5:29 AM

As for the fact that you don't get an email when another user logs a note, please double-check that you are actually a follower on that issue. Following the project only makes you a follower of new issues created for it, but it does not do anything for old issues, you have to manually click "Follow" on them. You should also double-check your user preferences (email address + notification setting), and keep in mind that you will not receive emails for your own messages/actions (a common mistake when you're testing the notifications)

Olivier Dony (odo)
on 11/8/13, 5:34 AM

Olivier, many thanks, but so far both points are unclear to me: First point (incoming email): we have only one email address, clients send messages to ("support@mycompany.com"). They don't know about "plus addressing", nor does our mediocre MTA (a well-known, overrated product from Redmond) support it. I like to have all emails go into the same project, but so far the issues are not assigned to any project.

Martin
on 11/8/13, 7:28 AM

Second point (following all issues): The whole point of my question, maybe this was not clear, was how to automatically follow all project issue changes by email. Neither I nor my colleagues do want to open every day ten new project issues just to follow them by email. We want to have this automatically for a bunch of users, just like Trac (trac.edgewall.org) supports. Yes, they would get spammed by issue changes, but they want it that way :~)

Martin
on 11/8/13, 7:32 AM

Martin, for the first point it depends on how you send the emails to OpenERP. Are you using a fetchmail rule that grabs them from the support mailbox in Exchange? If yes, try the following: go to Settings/Technical/Email/Aliases (need Tech Features) and create a new alias with the following settings: Aliased Model: Project Issue, Owner: Administrator, Record Thread ID: 0, Default Values: {'project_id': YOUR_PROJECT_ID}. Make sure to replace "YOUR_PROJECT_ID" with the ID of your support project. Then try to send another email to support@yourcompany.com.

Olivier Dony (odo)
on 11/8/13, 9:51 AM

MS Exchange does not seem to support "plus addressing" (see this question ) so you cannot use this technique.

Olivier Dony (odo)
on 11/8/13, 9:52 AM

For the second point: No, you do not have to manually follow each issue. If you follow the project you will automatically be added as a follower to all new issues assigned to this project. But my point was that this works only for new issues. If you were not a follower of this support project in the past, you are not a follower of the old issues. So you need to test with a new issue created after you started to follow the project. Please double-check that you are indeed automatically added as follower, and that you do receive an email when a colleague posts on that issue.

Olivier Dony (odo)
on 11/8/13, 10:02 AM

Olivier, again many thanks! Setting the alias and adding the followers was easy and new project issues are now created with the right project and the right list of followers. However, no email is sent out, when a user logs a note on such a project issue, only when the issue is created. Nobody gets an email, despite having "All Messages" selected in the preferences. There must be another hidden knob, I missed so far :~) Getting closer...

Martin
on 11/8/13, 11:06 AM

Are you sure you are logging new notes as a different user? You will never get notifications for your own actions or messages, so make sure you log notes as user A while user B is a follower, and user B should get an email. I assume other email notifications from the system are properly sent out, ruling out a basic problem in the outgoing mail server settings, right? Can you check if the user who is supposed to receive the emails does get a notification in Messaging/Inbox inside OpenERP? You can also check the outgoing email queue in Settings/Email/Emails to see if anything is stuck there...

Olivier Dony (odo)
on 11/8/13, 12:11 PM

Yes, in fact two different users logged notes to a project issue, but nobody got notices, not even in the Messaging/Inbox. We get email in other cases, however, e.g. when an issue is opened or closed, so email seems to work in general. There is just no message created in case of "logged note". When I review the message under Settings/Technical/Email/Messages, there is nobody in the field "Notified partners". Maybe there is an option, whether logged notes are sent or not?

Martin
on 11/8/13, 1:26 PM

Hi, how to do it programmatically?

Nanie BE
on 8/28/14, 3:55 AM
0
joachim grubelnik
On 11/6/14, 4:31 AM

One question regarding this thread...

normaly in a standard installation there is

project+xxxx@domain.com as the basic alias for everthing in this model. everything after "project" is added but i need to change the basic project. (hardcoded or configureable somewhere ? )

i have searched around but could not find anything to change the "project" to something else as the NEW STANARD in this DB like .... 

example why i want this ... 

2 companies --> one domain 2 databases to separate the companies.... so i wanted to separate it with a subdomain at least 

or having 2 different mailboxes used... BUT in one domain i can only have ONE Mailbox called "project"

so i wanted to use projectcompany1@company.com and projectcompany2@company.com as mailbox but i need to change the model alias base from "project" to projectcompany1 or 2 in each DB ...

QUESTION is ...

is it possible ? where ? i know only the place of the project itself and change the mailalias on every project creation for theproject, but this means taking a lot of care cause standard is still "project" ..... so if a user forget to do this mails gets lost ... 

is it a good idea ?

otherwise YES I KNOW make a second domain for this kind of setup ..... but lets say this is not possible 

would be nice to read from someone about this  

cheers joe

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

2 follower(s)

Stats

Asked: 11/7/13, 1:08 PM
Seen: 8169 times
Last updated: 4/21/15, 1:29 PM