Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] mail_post_defer: deferred message posting with queue #1001

Merged
merged 1 commit into from
Mar 9, 2023

Conversation

yajo
Copy link
Member

@yajo yajo commented Nov 18, 2022

This module enhances mail threads by using the mail queue by default.

Without this module, Odoo attempts to notify recipients of your message immediately.
If your mail server is slow or you have many followers, this can mean a lot of time.
Install this module and make Odoo more snappy!

All emails will be kept in the outgoing queue by at least 30 seconds,
giving you some time to re-think what you wrote. During that time,
you can still delete the message and start again.

Usage

To use this module, you need to:

  1. Go to the form view of any record that has a mail thread. It can be a partner, for example.
  2. Post a message.

The mail is now in the outgoing mail queue. It will be there for at least 30
seconds. It will be really sent the next time the "Mail: Email Queue Manager"
cron job is executed.

While the message has not been yet sent:

  1. Hover over the little envelope. You will see a paper airplane icon,
    indicating it is still outgoing.
  2. Hover over the message and click on the little trash icon to delete it.
    Mails will not be sent.

Configuration

You need to do nothing. The module is configured appropriately out of the box.

However, please notice that the mail queue processing is made by a cron job.
This is normal Odoo behavior, not specific to this module. However, since you
will start using that queue for every message posted by any user in any thread,
you will probably want to increase the that job's frequency.

To do so:

  1. Log in with an administrator user.
  2. Activate developer mode.
  3. Go to Settings > Technical > Automation > Scheduled Actions.
  4. Edit the action named "Mail: Email Queue Manager".
  5. Lower down the frequency in the field Execute Every. Recommended: 1 minute.

@moduon MT-1579 MT-2480

@rafaelbn rafaelbn added this to the 15.0 milestone Nov 18, 2022
Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality 👍

@rafaelbn rafaelbn self-requested a review November 18, 2022 14:26
Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works and solve the problem but a second UX-review I don't see clearly the UX, because, this would be problematic for user. We should think about that.

@yajo yajo marked this pull request as draft November 24, 2022 07:44
@yajo yajo force-pushed the 15.0-mail_message_post_queue branch from b4a1b62 to d422346 Compare March 8, 2023 10:01
@yajo yajo marked this pull request as ready for review March 8, 2023 10:02
@yajo yajo changed the title [ADD] mail_thread_queue: deferred message posting with queue [ADD] mail_post_defer: deferred message posting with queue Mar 8, 2023
Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Shide
Copy link
Contributor

Shide commented Mar 9, 2023

Will be interesting if defer time (30 sec on code) could be parametrized?

@pedrobaeza
Copy link
Member

The base seems similar to OCA/queue#119

@yajo
Copy link
Member Author

yajo commented Mar 9, 2023

Will be interesting if defer time (30 sec on code) could be parametrized?

Makes sense, although the real time for sending an email will be more about 1:00-1:30 minutes minimum. This defer time is to guarantee that, if you're running the mail queue cron at its minimal cadence (once per minute) and let's say you send a message 3 seconds before it's executed, you always have at least 30s of defer.

So, even if you parametrize it, there's no guarantee that messages will be sent in that time.

Also, everybody loves this feature in Gmail and other mail clients, but I have never seen an option to configure the deferring time. At most, I see the option to enable it or not. So, chances are that real world users never need to configure this. That's why I decided to hardcode the value.

IMHO we can keep it as it is and support the param later if we really see it's needed.

The base seems similar to OCA/queue#119

Thanks, I didn't know that module! However IIUC both modules would be complementary. mail_queue_job replaces the mail queue cron for a queue job implementation, which is probably more snappy and reliable. This one instead:

  • Makes messages sent from the chatter deferred.
  • Lets the user undo queued messages.

If you install both, you probably can have the best of both worlds, but I don't see any feature overlap or interdependency.

I liked from that one the init hook. I think I'll add one here, because when you install this module, chances are you want to have the mail queue cron as fast as possible.

@yajo yajo marked this pull request as draft March 9, 2023 08:47
- Faster because the email sending doesn't block the UI.
- Safer because users can undo mails while they're still not sent.

@moduon MT-1579 MT-2480
@yajo yajo force-pushed the 15.0-mail_message_post_queue branch from d422346 to 0d66ab7 Compare March 9, 2023 09:12
@yajo yajo marked this pull request as ready for review March 9, 2023 09:12
@yajo
Copy link
Member Author

yajo commented Mar 9, 2023

Install hook added. I also added @Shide's suggestion to roadmap, just to keep track of that idea.

Copy link
Contributor

@Shide Shide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM
Functionally Reviewed: Direct message to other user doesn't wait 30s.

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@yajo
Copy link
Member Author

yajo commented Mar 9, 2023

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 15.0-ocabot-merge-pr-1001-by-yajo-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 7fe80ec into OCA:15.0 Mar 9, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at ce38678. Thanks a lot for contributing to OCA. ❤️

@yajo yajo deleted the 15.0-mail_message_post_queue branch March 10, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants