From 058f4b3988550985f8f053578241192c91cbbfc5 Mon Sep 17 00:00:00 2001 From: houssine Date: Mon, 10 Jul 2017 10:26:10 +0200 Subject: [PATCH] [FIX] select the right mail template to send instead according the status of the member --- easy_my_coop/models/account_invoice.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/easy_my_coop/models/account_invoice.py b/easy_my_coop/models/account_invoice.py index 09728c5..9e56fae 100644 --- a/easy_my_coop/models/account_invoice.py +++ b/easy_my_coop/models/account_invoice.py @@ -19,12 +19,17 @@ class account_invoice(models.Model): def set_cooperator_effective(self, effective_date): # flag the partner as a effective member obj_sequence = self.env['ir.sequence'] + + mail_template_name = 'Payment Received Confirmation - Send By Email' + # if not yet cooperator we generate a cooperator number if self.partner_id.member == False : sequence_id = obj_sequence.search([('name','=','Subscription Register')])[0] sub_reg_num = sequence_id.next_by_id() self.partner_id.write({'member':True, 'cooperator_register_number':int(sub_reg_num)}) + else: + mail_template_name = 'Share Increase - Payment Received Confirmation - Send By Email' sequence_operation = obj_sequence.search([('name','=','Register Operation')])[0] sub_reg_operation = sequence_operation.next_by_id() @@ -44,10 +49,6 @@ class account_invoice(models.Model): 'share_unit_price':line.price_unit, 'effective_date':effective_date}) - mail_template_name = 'Payment Received Confirmation - Send By Email' - if self.partner_id.member : - mail_template_name = 'Share Increase - Payment Received Confirmation - Send By Email' - email_template_obj = self.env['mail.template'] certificat_email_template = email_template_obj.search([('name', '=', mail_template_name)])[0] # we send the email with the certificat in attachment