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

[16.0] [MIG] email_template_config #301

Closed
wants to merge 14 commits into from

Conversation

houssine78 and others added 13 commits July 19, 2023 14:23
[REF] pre-commit automatic  linting

[REF] lint xml

[REF] optimize imports

[WIP] add readmes and fix manifests

[REF] lint csv

[REF] flake8 fixes

[REF] class-camelcase

[REF] method-compute

[REF] duplicate-id-csv

pre-commit second pass

[IMP] pre-commit run -a

[IMP] addons readme and table

[FIX] Run pre-commit

Signed-off-by: Carmen Bianca Bakker <[email protected]>

[UPD] Update email_template_config.pot
@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2023

Codecov Report

Merging #301 (0a897a4) into 16.0 (e110213) will decrease coverage by 0.36%.
The diff coverage is 87.50%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             16.0     #301      +/-   ##
==========================================
- Coverage   97.73%   97.37%   -0.36%     
==========================================
  Files          12       15       +3     
  Lines         221      229       +8     
  Branches       30       30              
==========================================
+ Hits          216      223       +7     
- Misses          1        2       +1     
  Partials        4        4              
Files Changed Coverage Δ
email_template_config/models/mail_template.py 83.33% <83.33%> (ø)
email_template_config/__init__.py 100.00% <100.00%> (ø)
email_template_config/models/__init__.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@carmenbianca carmenbianca left a comment

Choose a reason for hiding this comment

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

LGTM, same comment as hugues

Copy link
Member

@robinkeunen robinkeunen left a comment

Choose a reason for hiding this comment

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

I actually suspect there is something wrong with this module, I read in our migration analysis tool :

à garder
Module indispensable pour les implémentations cooperator (notamment) car en standard tous les mail template sont en ""force send"". Du coup, si le serveur mail n'est pas OP, impossible de lettrer les demandes de libération."

I see many wrong things

  • why does the cooperator modules depend on this module fo function properly while not declaring the dependency ?
  • force_send's default value is False (that is, put in the email queue). Therefore it should not block the mail unless we `send_mail(id, force_send=True)
  • it should be named mail_template_force_send or the like

The need for this module comes from (version 12)

# cooperator/models/account_invoice.py
class AccountInvoice(models.Model):
    def set_cooperator_effective(self, effective_date):
        ...
        self.create_user(self.partner_id)

    def create_user(self, partner):
        ...
        user.sudo().with_context({"create_user": True}).action_reset_password()

# auth_signup/models/res_users.py
class ResUsers(models.Model):
    def action_reset_password(self):
        ...
        template.with_context(lang=user.lang).send_mail(user.id, force_send=True, raise_exception=True)

The send_mail(force_send=True) waits for the mail to be sent and blocks the process if it fails. There should be a better wait to fix this.
By using oca/queue for example.

@victor-champonnois
Copy link
Member Author

victor-champonnois commented Dec 19, 2023

  • why does the cooperator modules depend on this module fo function properly while not declaring the dependency ?

It does not strictly depend on it. It might be required for implementation for which we don't want or can't send email to cooperators

  • force_send's default value is False (that is, put in the email queue). Therefore it should not block the mail unless we `send_mail(id, force_send=True)

and we indeed do in cooperator/models/account_invoice, line 197 : email_template.sudo().send_mail(self.id, True). I don't know why the force send is set in this line, though.

  • it should be named mail_template_force_send or the like

Yes good idea

@huguesdk
Copy link
Member

note: while in version 12 and 14, there are indeed 2 mail messages sent with force_send=True, this argument has been removed from all send_mail() calls in version 16.

@robinkeunen
Copy link
Member

@huguesdk indeed but a force_send=True is still implicitely called by action_reset_password :

https://github.com/OCA/OCB/blob/b9fd7c5ac938fb0fc265abc7a4d202c3fd090b7b/addons/auth_signup/models/res_users.py#L224

@robinkeunen
Copy link
Member

Discuté sur la tâche : ne pas porter 💩

@robinkeunen robinkeunen deleted the 16.0-mig-email_template_config branch January 11, 2024 15:26
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.

8 participants