OCA / cooperative

GNU Affero General Public License v3.0
11 stars 22 forks source link

cooperator: Confirmation e-mail is sent too soon #76

Open carmenbianca opened 1 year ago

carmenbianca commented 1 year ago

Module

cooperator

Describe the bug

In the create() method of subscription.request, there is this line:

        subscription_request._send_confirmation_mail()

I have two objections to this:

  1. Most importantly, programmatically, this is Bad. Odoo already violates this rule a little bit, but constructors shouldn't have side effects beyond creating the thing you want to be created. Sending an e-mail is an especially egregious side effect.
  2. Functionally, this isn't great. The request is created in draft, and I wouldn't expect Odoo to send e-mails of in-draft objects until I click on a button that is semantically equivalent to 'I have finished filling in most/all the fields; this record is no longer in draft'.

The reason, I believe, that this line exists, is for people who submit their subscription request online. The flow is this:

  1. User fills in their details on the online form.
  2. User clicks on 'submit'.
  3. Odoo validates the data.
  4. Assuming it's valid, Odoo creates the request record.
  5. While creating the request record, an e-mail is sent that assures the user that the request was correctly received and that the cooperative will process their request.

To Reproduce

Affected versions: All, I think. 14.0 at least.

Steps to reproduce the behavior:

  1. Create a request.

Expected behavior I see two obvious solutions:

  1. Add a state after draft. When switching to this state, send the e-mail. The name of this state could be confirmed, processing, sen[d|t], or some such. This implies a change in workflow for people working with this module. There is a reverted commit in #73 that does this.
  2. Just remove the line, and in the cooperator_website code, add a line to send the e-mail after the request is created. This implies a change (reduction) in functionality: confirmation e-mails are no longer sent when requests are manually created in the back-end.

Additional context Add any other context about the problem here. (e.g. OS, Python version, ...)

github-actions[bot] commented 11 months ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

carmenbianca commented 11 months ago

bump