diff --git a/cooperator/__manifest__.py b/cooperator/__manifest__.py index 7b4fb039b..d49bdff41 100644 --- a/cooperator/__manifest__.py +++ b/cooperator/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Cooperators", "summary": "Manage your cooperators", - "version": "14.0.1.6.0", + "version": "14.0.1.7.0", "depends": [ "base", "web", diff --git a/cooperator/data/mail_template_data.xml b/cooperator/data/mail_template_data.xml index ae00fb716..7dd50e196 100644 --- a/cooperator/data/mail_template_data.xml +++ b/cooperator/data/mail_template_data.xml @@ -35,7 +35,7 @@

Do not forget to add the structured communication to the payment.

-

Sustainably your,

+

Sustainably yours,

${object.company_id.name}.

% if object.company_id.street: @@ -94,7 +94,7 @@

If you have any question, do not hesitate to contact us.


-

Sustainably your,

+

Sustainably yours,

${object.company_id.name}.

% if object.company_id.street: @@ -216,7 +216,7 @@

If you have any question, do not hesitate to contact us.


-

Sustainably your,

+

Sustainably yours,

${object.company_id.name}.

% if object.company_id.street: @@ -279,7 +279,7 @@

Find in attachment your ${object.env.company.name} certificate.

Thank you for choosing ${object.env.company.name or 'us'}!


-

Sustainably your,

+

Sustainably yours,

${object.env.company.name}.

% if object.env.company.street: @@ -344,7 +344,7 @@

Find in attachment your ${object.env.company.name} certificate.

Thank you for trusting ${object.env.company.name or 'us'}!


-

Sustainably your,

+

Sustainably yours,

${object.env.company.name}.

% if object.env.company.street: @@ -407,7 +407,7 @@

Find in attachment your ${object.env.company.name} certificate.

Thank you for choosing ${object.env.company.name or 'us'}!


-

Sustainably your,

+

Sustainably yours,

${object.env.company.name}.

% if object.env.company.street: @@ -470,7 +470,7 @@

Find in attachment your ${object.env.company.name} certificate.

Thank you for choosing ${object.env.company.name or 'us'}!


-

Sustainably your,

+

Sustainably yours,

${object.env.company.name}.

% if object.env.company.street: diff --git a/cooperator/i18n/ca_ES.po b/cooperator/i18n/ca_ES.po index 32e65d3fc..38f9d6db1 100644 --- a/cooperator/i18n/ca_ES.po +++ b/cooperator/i18n/ca_ES.po @@ -138,7 +138,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -189,7 +189,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -239,7 +239,7 @@ msgid "" "

Do not forget to add the structured communication to the payment.\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -289,7 +289,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for trusting ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -339,7 +339,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -390,7 +390,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -440,7 +440,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -2776,7 +2776,7 @@ msgstr "" #~ "p>\n" #~ "

Thank you for trusting ${object.company_id.name or 'us'}!

\n" #~ "
\n" -#~ "

Sustainably your,

\n" +#~ "

Sustainably yours,

\n" #~ "

${object.company_id.name}.

\n" #~ "\n" #~ " % if object.company_id.street:\n" @@ -2874,7 +2874,7 @@ msgstr "" #~ "p>\n" #~ "

Thank you for choosing ${object.company_id.name or 'us'}!

\n" #~ "
\n" -#~ "

Sustainably your,

\n" +#~ "

Sustainably yours,

\n" #~ "

${object.company_id.name}.

\n" #~ "\n" #~ " % if object.company_id.street:\n" @@ -2972,7 +2972,7 @@ msgstr "" #~ "p>\n" #~ "

Thank you for choosing ${object.company_id.name or 'us'}!

\n" #~ "
\n" -#~ "

Sustainably your,

\n" +#~ "

Sustainably yours,

\n" #~ "

${object.company_id.name}.

\n" #~ "\n" #~ " % if object.company_id.street:\n" @@ -3071,7 +3071,7 @@ msgstr "" #~ "p>\n" #~ "

Thank you for choosing ${object.company_id.name or 'us'}!

\n" #~ "
\n" -#~ "

Sustainably your,

\n" +#~ "

Sustainably yours,

\n" #~ "

${object.company_id.name}.

\n" #~ "\n" #~ " % if object.company_id.street:\n" @@ -3172,7 +3172,7 @@ msgstr "" #~ "

If you have any question, do not hesitate to contact us.

\n" #~ "
\n" #~ "\n" -#~ "

Sustainably your,

\n" +#~ "

Sustainably yours,

\n" #~ "

${object.company_id.name}.

\n" #~ "\n" #~ " % if object.company_id.street:\n" @@ -3273,7 +3273,7 @@ msgstr "" #~ "

If you have any question, do not hesitate to contact us.

\n" #~ "
\n" #~ "\n" -#~ "

Sustainably your,

\n" +#~ "

Sustainably yours,

\n" #~ "

${object.company_id.name}.

\n" #~ "\n" #~ " % if object.company_id.street:\n" @@ -3370,7 +3370,7 @@ msgstr "" #~ "

Do not forget to add the structured communication to the payment.\n" #~ "\n" -#~ "

Sustainably your,

\n" +#~ "

Sustainably yours,

\n" #~ "

${object.company_id.name}.

\n" #~ "\n" #~ " % if object.company_id.street:\n" diff --git a/cooperator/i18n/cooperator.pot b/cooperator/i18n/cooperator.pot index eb134250e..5eaef1f1e 100644 --- a/cooperator/i18n/cooperator.pot +++ b/cooperator/i18n/cooperator.pot @@ -77,7 +77,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -123,7 +123,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -167,7 +167,7 @@ msgid "" "\n" "

Do not forget to add the structured communication to the payment.

\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -213,7 +213,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for trusting ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -259,7 +259,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -305,7 +305,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -351,7 +351,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" diff --git a/cooperator/i18n/es.po b/cooperator/i18n/es.po index d47af5a3a..b79772c44 100644 --- a/cooperator/i18n/es.po +++ b/cooperator/i18n/es.po @@ -90,7 +90,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -141,7 +141,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -191,7 +191,7 @@ msgid "" "

Do not forget to add the structured communication to the payment.\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -241,7 +241,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for trusting ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -291,7 +291,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -342,7 +342,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -392,7 +392,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" diff --git a/cooperator/i18n/fr.po b/cooperator/i18n/fr.po index 5f1eb4ac3..0694b5a17 100644 --- a/cooperator/i18n/fr.po +++ b/cooperator/i18n/fr.po @@ -135,7 +135,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -234,7 +234,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -330,7 +330,7 @@ msgid "" "

Do not forget to add the structured communication to the payment.\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -426,7 +426,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for trusting ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -522,7 +522,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -619,7 +619,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -714,7 +714,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" diff --git a/cooperator/i18n/fr_BE.po b/cooperator/i18n/fr_BE.po index d0d627b02..a29ad60de 100644 --- a/cooperator/i18n/fr_BE.po +++ b/cooperator/i18n/fr_BE.po @@ -87,7 +87,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -138,7 +138,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -188,7 +188,7 @@ msgid "" "

Do not forget to add the structured communication to the payment.\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -284,7 +284,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for trusting ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -334,7 +334,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -385,7 +385,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -435,7 +435,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" diff --git a/cooperator/i18n/nl_BE.po b/cooperator/i18n/nl_BE.po index 818dd6944..6a3ae8248 100644 --- a/cooperator/i18n/nl_BE.po +++ b/cooperator/i18n/nl_BE.po @@ -89,7 +89,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -140,7 +140,7 @@ msgid "" "

If you have any question, do not hesitate to contact us.

\n" "
\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -190,7 +190,7 @@ msgid "" "

Do not forget to add the structured communication to the payment.\n" "\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.company_id.name}.

\n" "\n" " % if object.company_id.street:\n" @@ -240,7 +240,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for trusting ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -290,7 +290,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -341,7 +341,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" @@ -391,7 +391,7 @@ msgid "" "

Find in attachment your ${object.env.company.name} certificate.

\n" "

Thank you for choosing ${object.env.company.name or 'us'}!

\n" "
\n" -"

Sustainably your,

\n" +"

Sustainably yours,

\n" "

${object.env.company.name}.

\n" "\n" " % if object.env.company.street:\n" diff --git a/cooperator/models/account_move.py b/cooperator/models/account_move.py index 406247447..81127dc78 100644 --- a/cooperator/models/account_move.py +++ b/cooperator/models/account_move.py @@ -61,10 +61,8 @@ def create_user(self, partner): def get_mail_template_certificate(self): if self.partner_id.member: - mail_template = "cooperator.email_template_certificat_increase" - else: - mail_template = "cooperator.email_template_certificat" - return self.env.ref(mail_template) + return self.company_id.get_cooperator_certificate_increase_mail_template() + return self.company_id.get_cooperator_certificate_mail_template() def get_sequence_register(self): return self.env.ref("cooperator.sequence_subscription", False) @@ -205,7 +203,7 @@ def action_invoice_paid(self): return True def _get_capital_release_mail_template(self): - return self.env.ref("cooperator.email_template_release_capital", False) + return self.company_id.get_cooperator_capital_release_mail_template() def send_capital_release_request_mail(self): if self.company_id.send_capital_release_email: diff --git a/cooperator/models/company.py b/cooperator/models/company.py index 653561b2c..6fd10182e 100644 --- a/cooperator/models/company.py +++ b/cooperator/models/company.py @@ -100,21 +100,78 @@ def _compute_base_logo(self): translate=True, help="Text to display aside the checkbox to approve the generic rules.", ) + cooperator_certificate_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Certificate email template", + domain=[("model", "=", "res.partner"), ("is_cooperator_template", "=", True)], + help="If left empty, the default global mail template will be used.", + ) + cooperator_certificate_increase_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Certificate increase email template", + domain=[("model", "=", "res.partner"), ("is_cooperator_template", "=", True)], + help="If left empty, the default global mail template will be used.", + ) send_certificate_email = fields.Boolean( string="Send certificate email", default=True ) + cooperator_confirmation_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Share confirmation email template", + domain=[ + ("model", "=", "subscription.request"), + ("is_cooperator_template", "=", True), + ], + help="If left empty, the default global mail template will be used.", + ) + cooperator_confirmation_company_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Company share confirmation email template", + domain=[ + ("model", "=", "subscription.request"), + ("is_cooperator_template", "=", True), + ], + help="If left empty, the default global mail template will be used.", + ) send_confirmation_email = fields.Boolean( string="Send confirmation email", default=True ) + cooperator_capital_release_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Capital release email template", + domain=[("model", "=", "account.move"), ("is_cooperator_template", "=", True)], + help="If left empty, the default global mail template will be used.", + ) send_capital_release_email = fields.Boolean( string="Send Capital Release email", default=True ) + cooperator_waiting_list_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Waiting list email template", + domain=[ + ("model", "=", "subscription.request"), + ("is_cooperator_template", "=", True), + ], + help="If left empty, the default global mail template will be used.", + ) send_waiting_list_email = fields.Boolean( string="Send Waiting List email", default=True ) + cooperator_share_transfer_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Share transfer email template", + domain=[("model", "=", "res.partner"), ("is_cooperator_template", "=", True)], + help="If left empty, the default global mail template will be used.", + ) send_share_transfer_email = fields.Boolean( string="Send Share Transfer Email", default=True ) + cooperator_share_update_mail_template = fields.Many2one( + comodel_name="mail.template", + string="Share update email template", + domain=[("model", "=", "res.partner"), ("is_cooperator_template", "=", True)], + help="If left empty, the default global mail template will be used.", + ) send_share_update_email = fields.Boolean( string="Send Share Update Email", default=True ) @@ -138,3 +195,59 @@ def onchange_financial_risk_approval_required(self): def onchange_generic_rules_approval_required(self): if self.generic_rules_approval_required: self.display_generic_rules_approval = True + + @api.model + def _get_cooperator_mail_template_fields(self): + return { + "cooperator_confirmation_mail_template": "cooperator.email_template_confirmation", + "cooperator_confirmation_company_mail_template": ( + "cooperator.email_template_confirmation_company" + ), + "cooperator_capital_release_mail_template": ( + "cooperator.email_template_release_capital" + ), + "cooperator_waiting_list_mail_template": "cooperator.email_template_waiting_list", + "cooperator_certificate_mail_template": "cooperator.email_template_certificat", + "cooperator_certificate_increase_mail_template": ( + "cooperator.email_template_certificat_increase" + ), + "cooperator_share_transfer_mail_template": ( + "cooperator.email_template_share_transfer" + ), + "cooperator_share_update_mail_template": "cooperator.email_template_share_update", + } + + def _get_cooperator_template(self, name): + self.ensure_one() + template = getattr(self, name) + if not template: + return self.env.ref(self._get_cooperator_mail_template_fields()[name]) + return template + + def get_cooperator_certificate_mail_template(self): + return self._get_cooperator_template("cooperator_certificate_mail_template") + + def get_cooperator_certificate_increase_mail_template(self): + return self._get_cooperator_template( + "cooperator_certificate_increase_mail_template" + ) + + def get_cooperator_confirmation_mail_template(self): + return self._get_cooperator_template("cooperator_confirmation_mail_template") + + def get_cooperator_confirmation_company_mail_template(self): + return self._get_cooperator_template( + "cooperator_confirmation_company_mail_template" + ) + + def get_cooperator_capital_release_mail_template(self): + return self._get_cooperator_template("cooperator_capital_release_mail_template") + + def get_cooperator_waiting_list_mail_template(self): + return self._get_cooperator_template("cooperator_waiting_list_mail_template") + + def get_cooperator_share_transfer_mail_template(self): + return self._get_cooperator_template("cooperator_share_transfer_mail_template") + + def get_cooperator_share_update_mail_template(self): + return self._get_cooperator_template("cooperator_share_update_mail_template") diff --git a/cooperator/models/operation_request.py b/cooperator/models/operation_request.py index 65e0a7145..4d4347dd5 100644 --- a/cooperator/models/operation_request.py +++ b/cooperator/models/operation_request.py @@ -276,10 +276,10 @@ def validate(self): ) def _get_share_transfer_mail_template(self): - return self.env.ref("cooperator.email_template_share_transfer", False) + return self.company_id.get_cooperator_share_transfer_mail_template() def _get_share_update_mail_template(self): - return self.env.ref("cooperator.email_template_share_update", False) + return self.company_id.get_cooperator_share_update_mail_template() def _send_share_transfer_mail( self, sub_register_line diff --git a/cooperator/models/subscription_request.py b/cooperator/models/subscription_request.py index 1d2486553..4c50bc53b 100644 --- a/cooperator/models/subscription_request.py +++ b/cooperator/models/subscription_request.py @@ -53,10 +53,8 @@ def get_required_field(self): def get_mail_template_notif(self, is_company=False): if is_company: - mail_template = "cooperator.email_template_confirmation_company" - else: - mail_template = "cooperator.email_template_confirmation" - return self.env.ref(mail_template, False) + return self.company_id.get_cooperator_confirmation_company_mail_template() + return self.company_id.get_cooperator_confirmation_mail_template() @api.constrains("share_product_id", "is_company") def _check_share_available_to_user(self): @@ -121,6 +119,10 @@ def create(self, vals): partner.cooperator = True subscription_request = super().create(vals) + # TODO: This should probably not be in the create method. There may need + # to be a stage after draft in which this e-mail is sent, or the e-mail + # should exclusively be sent from `cooperator_website`. See #73 for + # some comments, and for a reverted implementation of the extra state. subscription_request._send_confirmation_mail() return subscription_request @@ -779,8 +781,8 @@ def cancel_subscription_request(self): def _send_waiting_list_mail(self): if self.company_id.send_waiting_list_email: - waiting_list_mail_template = self.env.ref( - "cooperator.email_template_waiting_list", False + waiting_list_mail_template = ( + self.company_id.get_cooperator_waiting_list_mail_template() ) waiting_list_mail_template.send_mail(self.id, True) diff --git a/cooperator/readme/newsfragments/73.feature.rst b/cooperator/readme/newsfragments/73.feature.rst new file mode 100644 index 000000000..a35cf443e --- /dev/null +++ b/cooperator/readme/newsfragments/73.feature.rst @@ -0,0 +1,2 @@ +Each company now has their own mail templates for cooperator-related e-mails. If +no template is set, the default (global) template is used. diff --git a/cooperator/tests/__init__.py b/cooperator/tests/__init__.py index 586162b33..14203466e 100644 --- a/cooperator/tests/__init__.py +++ b/cooperator/tests/__init__.py @@ -1 +1,2 @@ from . import test_cooperator +from . import test_mail_templates diff --git a/cooperator/tests/test_mail_templates.py b/cooperator/tests/test_mail_templates.py new file mode 100644 index 000000000..44cbb8d41 --- /dev/null +++ b/cooperator/tests/test_mail_templates.py @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: 2023 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo.tests.common import SavepointCase + + +class TestMailTemplates(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.default_template = cls.env.ref("cooperator.email_template_confirmation") + + def test_new_company_gets_default_template(self): + """ + When creating a company, the mail template defaults to the default one. + """ + company = self.env["res.company"].create({"name": "Test Company"}) + self.assertEqual( + company.get_cooperator_confirmation_mail_template(), self.default_template + ) + + def test_overwrite_template(self): + """By setting the field, the get function no longer returns the default + mail template. + """ + company = self.env["res.company"].create({"name": "Test Company"}) + template = self.env["mail.template"].create({"name": "Test"}) + company.cooperator_confirmation_mail_template = template + self.assertEqual(company.get_cooperator_confirmation_mail_template(), template) diff --git a/cooperator/views/res_company_view.xml b/cooperator/views/res_company_view.xml index d74baefeb..f9bb9db00 100644 --- a/cooperator/views/res_company_view.xml +++ b/cooperator/views/res_company_view.xml @@ -39,8 +39,32 @@ + + + + + + + + +