diff --git a/easy_my_coop/models/account_invoice.py b/easy_my_coop/models/account_invoice.py index b485a91..acb64e6 100644 --- a/easy_my_coop/models/account_invoice.py +++ b/easy_my_coop/models/account_invoice.py @@ -26,19 +26,19 @@ class account_invoice(models.Model): # flag the partner as a effective member obj_sequence = self.env['ir.sequence'] - mail_template_name = 'Payment Received Confirmation - Send By Email' + mail_template_id = 'easy_my_coop.email_template_certificat' # if not yet cooperator we generate a cooperator number if self.partner_id.member is False and self.partner_id.old_member is False: - sequence_id = obj_sequence.search([('name', '=', 'Subscription Register')])[0] + sequence_id = self.env.ref('easy_my_coop.sequence_subscription', False) sub_reg_num = sequence_id.next_by_id() self.partner_id.write({'member': True, 'old_member': False, 'cooperator_register_number': int(sub_reg_num)}) elif self.partner_id.old_member: self.partner_id.write({'member': True, 'old_member': False}) else: - mail_template_name = 'Share Increase - Payment Received Confirmation - Send By Email' - sequence_operation = obj_sequence.search([('name', '=', 'Register Operation')])[0] + mail_template_id = 'easy_my_coop.email_template_certificat_increase' + sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False) sub_reg_operation = sequence_operation.next_by_id() for line in self.invoice_line_ids: @@ -58,7 +58,8 @@ class account_invoice(models.Model): 'effective_date': effective_date}) email_template_obj = self.env['mail.template'] - certificat_email_template = email_template_obj.search([('name', '=', mail_template_name)])[0] + certificat_email_template = self.env.ref(mail_template_id, False) + #certificat_email_template = email_template_obj.search([('name', '=', mail_template_name)])[0] # we send the email with the certificat in attachment certificat_email_template.send_mail(self.partner_id.id, False) diff --git a/easy_my_coop/models/coop.py b/easy_my_coop/models/coop.py index 4b8c7a6..d84a99d 100644 --- a/easy_my_coop/models/coop.py +++ b/easy_my_coop/models/coop.py @@ -48,7 +48,7 @@ class subscription_request(models.Model): vals['already_cooperator'] = True subscr_request = super(subscription_request, self).create(vals) mail_template_obj = self.env['mail.template'] - confirmation_mail_template = mail_template_obj.search([('name', '=', 'Confirmation Email')])[0] + certificat_email_template = self.env.ref('easy_my_coop.email_template_confirmation', False) confirmation_mail_template.send_mail(subscr_request.id) return subscr_request @@ -62,7 +62,7 @@ class subscription_request(models.Model): vals['already_cooperator'] = True subscr_request = super(subscription_request, self).create(vals) mail_template_obj = self.env['mail.template'] - confirmation_mail_template = mail_template_obj.search([('name', '=', 'Company Confirmation Email')])[0] + certificat_email_template = self.env.ref('easy_my_coop.email_template_confirmation_company', False) confirmation_mail_template.send_mail(subscr_request.id, True) return subscr_request diff --git a/easy_my_coop/models/operation_request.py b/easy_my_coop/models/operation_request.py index ecfbe05..93dbec1 100644 --- a/easy_my_coop/models/operation_request.py +++ b/easy_my_coop/models/operation_request.py @@ -149,6 +149,7 @@ class operation_request(models.Model): effective_date = self.get_date_now() ir_sequence = self.env['ir.sequence'] sub_request = self.env['subscription.request'] + email_template_obj = self.env['mail.template'] for rec in self: rec.validate() @@ -173,7 +174,7 @@ class operation_request(models.Model): if rec.receiver_not_member: partner = rec.subscription_request.create_coop_partner() #get cooperator number - sequence_id = ir_sequence.search([('name','=','Subscription Register')])[0] + sequence_id = self.env.ref('easy_my_coop.sequence_subscription', False) sub_reg_num = sequence_id.next_by_id() partner_vals = sub_request.get_eater_vals(partner, rec.share_product_id) partner_vals['member'] = True @@ -197,7 +198,8 @@ class operation_request(models.Model): else: raise ValidationError(_("This operation is not yet implemented.")) - sequence_operation = ir_sequence.search([('name','=','Register Operation')])[0] + #sequence_operation = ir_sequence.search([('name','=','Register Operation')])[0] + sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False) sub_reg_operation = sequence_operation.next_by_id() values = {'name':sub_reg_operation,'register_number_operation':int(sub_reg_operation), @@ -208,14 +210,13 @@ class operation_request(models.Model): rec.write({'state':'done'}) - email_template_obj = self.env['mail.template'] if rec.operation_type == 'transfer': values['partner_id_to'] = rec.partner_id_to.id - certificat_email_template = email_template_obj.search([('name', '=', "Share transfer - Send By Email")])[0] + certificat_email_template = self.env.ref('easy_my_coop.email_template_share_transfer', False) certificat_email_template.send_mail(rec.partner_id_to.id, False) self.env['subscription.register'].create(values) - certificat_email_template = email_template_obj.search([('name', '=', "Share update - Send By Email")])[0] + certificat_email_template = self.env.ref('easy_my_coop.email_template_share_update', False) certificat_email_template.send_mail(rec.partner_id.id, False) \ No newline at end of file