From f22d939ad73be63d64cbd508a82a146b7d3c3d06 Mon Sep 17 00:00:00 2001 From: houssine Date: Fri, 8 Nov 2019 15:32:19 +0100 Subject: [PATCH 1/9] [IMP] add easy my coop flag on mail template --- easy_my_coop/__manifest__.py | 2 +- easy_my_coop/data/mail_template_data.xml | 8 ++++++- easy_my_coop/models/__init__.py | 1 + easy_my_coop/models/mail_template.py | 22 +++++++++++++++++++ easy_my_coop/views/email_template_view.xml | 1 + easy_my_coop_loan/data/mail_template_data.xml | 2 ++ easy_my_coop_loan/models/__init__.py | 1 + easy_my_coop_loan/models/mail_template.py | 15 +++++++++++++ .../data/mail_template_data.xml | 6 ++--- .../models/mail_template.py | 18 ++++++++++----- 10 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 easy_my_coop/models/mail_template.py create mode 100644 easy_my_coop_loan/models/mail_template.py diff --git a/easy_my_coop/__manifest__.py b/easy_my_coop/__manifest__.py index 310f184..03179d2 100644 --- a/easy_my_coop/__manifest__.py +++ b/easy_my_coop/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Easy My Coop', - 'version': '12.0.2.0.2', + 'version': '12.0.3.0.1', 'depends': [ 'base', 'web', diff --git a/easy_my_coop/data/mail_template_data.xml b/easy_my_coop/data/mail_template_data.xml index be29a3e..ca4a566 100644 --- a/easy_my_coop/data/mail_template_data.xml +++ b/easy_my_coop/data/mail_template_data.xml @@ -15,6 +15,7 @@ ${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''} ${object.partner_id.lang} + @@ -65,6 +66,7 @@ ${object.lang} + @@ -117,6 +119,7 @@ ${object.lang} + @@ -166,7 +169,6 @@ Payment Received Confirmation - Send By Email ${(object.company_id.coop_email_contact or object.user_id.email)|safe} Payment Received Confirmation - ${object.id} ${(object.company_id.coop_email_contact or object.user_id.email)|safe} @@ -174,6 +176,7 @@ Certificat ${(object.cooperator_register_number or '')} ${object.lang} + @@ -228,6 +231,7 @@ Certificat ${(object.cooperator_register_number or '')} ${object.lang} + @@ -282,6 +286,7 @@ Certificat ${(object.cooperator_register_number or '')} ${object.lang} + @@ -336,6 +341,7 @@ Certificat ${(object.cooperator_register_number or '')} ${object.lang} + diff --git a/easy_my_coop/models/__init__.py b/easy_my_coop/models/__init__.py index 9f09fa5..38eb166 100644 --- a/easy_my_coop/models/__init__.py +++ b/easy_my_coop/models/__init__.py @@ -6,3 +6,4 @@ from . import account_invoice from . import company from . import res_partner_bank from . import account_journal +from . import mail_template diff --git a/easy_my_coop/models/mail_template.py b/easy_my_coop/models/mail_template.py new file mode 100644 index 0000000..76be7e0 --- /dev/null +++ b/easy_my_coop/models/mail_template.py @@ -0,0 +1,22 @@ +from odoo import models, fields + +EMAIL_TEMPLATE_IDS = [ + "easy_my_coop.email_template_release_capital", + "easy_my_coop.email_template_confirmation", + "easy_my_coop.email_template_confirmation_company", + "easy_my_coop.email_template_certificat", + "easy_my_coop.email_template_certificat_increase", + "easy_my_coop.email_template_share_transfer", + "easy_my_coop.email_template_share_update" + ] + + +class MailTemplate(models.Model): + _inherit = "mail.template" + + def init(self): + for template_id in EMAIL_TEMPLATE_IDS: + mail_template = self.env.ref(template_id) + mail_template.easy_my_coop = True + + easy_my_coop = fields.Boolean(string="Easy my coop mail template") diff --git a/easy_my_coop/views/email_template_view.xml b/easy_my_coop/views/email_template_view.xml index 3b54efb..6834a80 100644 --- a/easy_my_coop/views/email_template_view.xml +++ b/easy_my_coop/views/email_template_view.xml @@ -7,6 +7,7 @@ mail.template form form,tree + [('easy_my_coop','=',True)] diff --git a/easy_my_coop_loan/data/mail_template_data.xml b/easy_my_coop_loan/data/mail_template_data.xml index eb67939..878ebad 100644 --- a/easy_my_coop_loan/data/mail_template_data.xml +++ b/easy_my_coop_loan/data/mail_template_data.xml @@ -13,6 +13,7 @@ ${object.partner_id.lang} + @@ -65,6 +66,7 @@ ${object.partner_id.lang} + diff --git a/easy_my_coop_loan/models/__init__.py b/easy_my_coop_loan/models/__init__.py index d997735..21d0546 100644 --- a/easy_my_coop_loan/models/__init__.py +++ b/easy_my_coop_loan/models/__init__.py @@ -2,3 +2,4 @@ from . import loan from . import loan_issue_line from . import interest_line from . import partner +from . import mail_template diff --git a/easy_my_coop_loan/models/mail_template.py b/easy_my_coop_loan/models/mail_template.py new file mode 100644 index 0000000..0efac37 --- /dev/null +++ b/easy_my_coop_loan/models/mail_template.py @@ -0,0 +1,15 @@ +from odoo import models + +EMAIL_TEMPLATE_IDS = [ + "easy_my_coop_loan.loan_subscription_confirmation", + "easy_my_coop_loan.loan_issue_payment_request", + ] + + +class MailTemplate(models.Model): + _inherit = "mail.template" + + def init(self): + for template_id in EMAIL_TEMPLATE_IDS: + mail_template = self.env.ref(template_id) + mail_template.easy_my_coop = True diff --git a/easy_my_coop_taxshelter_report/data/mail_template_data.xml b/easy_my_coop_taxshelter_report/data/mail_template_data.xml index 82d01bc..d896022 100644 --- a/easy_my_coop_taxshelter_report/data/mail_template_data.xml +++ b/easy_my_coop_taxshelter_report/data/mail_template_data.xml @@ -1,4 +1,4 @@ - + @@ -11,6 +11,7 @@ ${object.partner_id.lang} +

Hello ${object.partner_id.name},

@@ -51,6 +52,5 @@ ]]>
-
-
+ diff --git a/easy_my_coop_taxshelter_report/models/mail_template.py b/easy_my_coop_taxshelter_report/models/mail_template.py index feffb2b..585c0bd 100644 --- a/easy_my_coop_taxshelter_report/models/mail_template.py +++ b/easy_my_coop_taxshelter_report/models/mail_template.py @@ -1,18 +1,25 @@ -# -*- coding: utf-8 -*- -from openerp import api, models +from odoo import api, models +EMAIL_TEMPLATE_IDS = [ + "easy_my_coop_taxshelter_report.email_template_tax_shelter_certificate", + ] -class MailTemplate(models.Model): +class MailTemplate(models.Model): _inherit = "mail.template" + def init(self): + for template_id in EMAIL_TEMPLATE_IDS: + mail_template = self.env.ref(template_id) + mail_template.easy_my_coop = True + @api.multi def send_mail_with_multiple_attachments(self, res_id, additional_attachments, force_send=False, raise_exception=False): """Generates a new mail message for the given template and record, - and schedules it for delivery through the ``mail`` + and schedules it for delivery through the ``mail`` module's scheduler. :param int res_id: id of the record to render the template with @@ -24,7 +31,8 @@ class MailTemplate(models.Model): """ self.ensure_one() Mail = self.env['mail.mail'] - Attachment = self.env['ir.attachment'] # TDE FIXME: should remove dfeault_type from context + # TDE FIXME: should remove dfeault_type from context + Attachment = self.env['ir.attachment'] # create a mail_mail based on values, without attachments values = self.generate_email(res_id) From dcb3c680fd3d03e373fd9dae8581ac432febcbe6 Mon Sep 17 00:00:00 2001 From: houssine Date: Thu, 21 Nov 2019 16:54:34 +0100 Subject: [PATCH 2/9] [FIX] comment init method --- easy_my_coop/models/mail_template.py | 18 ++++-------------- easy_my_coop_loan/data/mail_template_data.xml | 1 - easy_my_coop_loan/models/mail_template.py | 13 ++++--------- .../models/mail_template.py | 12 ++++-------- 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/easy_my_coop/models/mail_template.py b/easy_my_coop/models/mail_template.py index 76be7e0..f346a21 100644 --- a/easy_my_coop/models/mail_template.py +++ b/easy_my_coop/models/mail_template.py @@ -1,22 +1,12 @@ from odoo import models, fields -EMAIL_TEMPLATE_IDS = [ - "easy_my_coop.email_template_release_capital", - "easy_my_coop.email_template_confirmation", - "easy_my_coop.email_template_confirmation_company", - "easy_my_coop.email_template_certificat", - "easy_my_coop.email_template_certificat_increase", - "easy_my_coop.email_template_share_transfer", - "easy_my_coop.email_template_share_update" - ] - class MailTemplate(models.Model): _inherit = "mail.template" - def init(self): - for template_id in EMAIL_TEMPLATE_IDS: - mail_template = self.env.ref(template_id) - mail_template.easy_my_coop = True +# def init(self): +# for template_id in EMAIL_TEMPLATE_IDS: +# mail_template = self.env.ref(template_id) +# mail_template.easy_my_coop = True easy_my_coop = fields.Boolean(string="Easy my coop mail template") diff --git a/easy_my_coop_loan/data/mail_template_data.xml b/easy_my_coop_loan/data/mail_template_data.xml index 878ebad..4c708c9 100644 --- a/easy_my_coop_loan/data/mail_template_data.xml +++ b/easy_my_coop_loan/data/mail_template_data.xml @@ -3,7 +3,6 @@ - Loan Subscription Confirmation Email ${(object.company_id.coop_email_contact or object.loan_issue_id.user_id.email)|safe} diff --git a/easy_my_coop_loan/models/mail_template.py b/easy_my_coop_loan/models/mail_template.py index 0efac37..12138c7 100644 --- a/easy_my_coop_loan/models/mail_template.py +++ b/easy_my_coop_loan/models/mail_template.py @@ -1,15 +1,10 @@ from odoo import models -EMAIL_TEMPLATE_IDS = [ - "easy_my_coop_loan.loan_subscription_confirmation", - "easy_my_coop_loan.loan_issue_payment_request", - ] - class MailTemplate(models.Model): _inherit = "mail.template" - def init(self): - for template_id in EMAIL_TEMPLATE_IDS: - mail_template = self.env.ref(template_id) - mail_template.easy_my_coop = True +# def init(self): +# for template_id in EMAIL_TEMPLATE_IDS: +# mail_template = self.env.ref(template_id) +# mail_template.easy_my_coop = True diff --git a/easy_my_coop_taxshelter_report/models/mail_template.py b/easy_my_coop_taxshelter_report/models/mail_template.py index 585c0bd..4d44e0a 100644 --- a/easy_my_coop_taxshelter_report/models/mail_template.py +++ b/easy_my_coop_taxshelter_report/models/mail_template.py @@ -1,17 +1,13 @@ from odoo import api, models -EMAIL_TEMPLATE_IDS = [ - "easy_my_coop_taxshelter_report.email_template_tax_shelter_certificate", - ] - class MailTemplate(models.Model): _inherit = "mail.template" - def init(self): - for template_id in EMAIL_TEMPLATE_IDS: - mail_template = self.env.ref(template_id) - mail_template.easy_my_coop = True +# def init(self): +# for template_id in EMAIL_TEMPLATE_IDS: +# mail_template = self.env.ref(template_id) +# mail_template.easy_my_coop = True @api.multi def send_mail_with_multiple_attachments(self, res_id, From 9a7cc8f5ff9fa315ba38fc7d3477c00b8cabd9fd Mon Sep 17 00:00:00 2001 From: houssine Date: Thu, 21 Nov 2019 22:22:30 +0100 Subject: [PATCH 3/9] [REFACT] get mail template from function in order to allow override. --- easy_my_coop/models/account_invoice.py | 10 +++++----- easy_my_coop/models/coop.py | 20 +++++++++++--------- easy_my_coop/models/operation_request.py | 14 ++++++++++---- easy_my_coop_loan/models/loan_issue_line.py | 14 ++++++++++---- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/easy_my_coop/models/account_invoice.py b/easy_my_coop/models/account_invoice.py index f3731fd..f5a366b 100644 --- a/easy_my_coop/models/account_invoice.py +++ b/easy_my_coop/models/account_invoice.py @@ -46,8 +46,10 @@ class account_invoice(models.Model): def get_mail_template_certificate(self): if self.partner_id.member: - return 'easy_my_coop.email_template_certificat_increase' - return 'easy_my_coop.email_template_certificat' + mail_template = 'easy_my_coop.email_template_certificat_increase' + else: + mail_template = 'easy_my_coop.email_template_certificat' + return self.env.ref(mail_template) def get_sequence_register(self): return self.env.ref('easy_my_coop.sequence_subscription', False) @@ -100,14 +102,12 @@ class account_invoice(models.Model): sub_register_obj = self.env['subscription.register'] share_line_obj = self.env['share.line'] - mail_template_id = self.get_mail_template_certificate() - self.set_membership() sequence_operation = self.get_sequence_operation() sub_reg_operation = sequence_operation.next_by_id() - certificate_email_template = self.env.ref(mail_template_id, False) + certificate_email_template = self.get_mail_template_certificate() for line in self.invoice_line_ids: sub_reg_vals = self.get_subscription_register_vals(line, diff --git a/easy_my_coop/models/coop.py b/easy_my_coop/models/coop.py index a747f31..2dff4a4 100644 --- a/easy_my_coop/models/coop.py +++ b/easy_my_coop/models/coop.py @@ -44,9 +44,10 @@ class SubscriptionRequest(models.Model): def get_mail_template_notif(self, is_company=False): if is_company: - return 'easy_my_coop.email_template_confirmation_company' + mail_template = 'easy_my_coop.email_template_confirmation_company' else: - return 'easy_my_coop.email_template_confirmation' + mail_template = 'easy_my_coop.email_template_confirmation' + return self.env.ref(mail_template, False) def is_member(self, vals, cooperator): if cooperator.member: @@ -57,7 +58,7 @@ class SubscriptionRequest(models.Model): @api.model def create(self, vals): partner_obj = self.env['res.partner'] - mail_template = self.get_mail_template_notif(False) + mail_template_notif = self.get_mail_template_notif(False) if not vals.get('partner_id'): cooperator = False @@ -80,14 +81,13 @@ class SubscriptionRequest(models.Model): cooperator.write({'cooperator': True}) subscr_request = super(SubscriptionRequest, self).create(vals) - confirmation_mail_template = self.env.ref(mail_template, False) - confirmation_mail_template.send_mail(subscr_request.id) + mail_template_notif.send_mail(subscr_request.id) return subscr_request @api.model def create_comp_sub_req(self, vals): - mail_template = self.get_mail_template_notif(True) + confirmation_mail_template = self.get_mail_template_notif(True) vals["name"] = vals['company_name'] if not vals.get('partner_id'): cooperator = self.env['res.partner'].get_cooperator_from_crn(vals.get('company_register_number')) @@ -97,7 +97,6 @@ class SubscriptionRequest(models.Model): vals['already_cooperator'] = True subscr_request = super(SubscriptionRequest, self).create(vals) - confirmation_mail_template = self.env.ref(mail_template, False) confirmation_mail_template.send_mail(subscr_request.id) return subscr_request @@ -401,9 +400,12 @@ class SubscriptionRequest(models.Model): } return res - def send_capital_release_request(self, invoice): + def get_capital_release_mail_template(self): template = 'easy_my_coop.email_template_release_capital' - email_template = self.env.ref(template, False) + return self.env.ref(template, False) + + def send_capital_release_request(self, invoice): + email_template = self.get_capital_release_mail_template() # we send the email with the capital release request in attachment # TODO remove sudo() and give necessary access right diff --git a/easy_my_coop/models/operation_request.py b/easy_my_coop/models/operation_request.py index f4b5ded..27594e8 100644 --- a/easy_my_coop/models/operation_request.py +++ b/easy_my_coop/models/operation_request.py @@ -206,6 +206,14 @@ class operation_request(models.Model): " the information before" " submitting")) + def get_share_trans_mail_template(self): + return self.env.ref('easy_my_coop.email_template_share_transfer', + False) + + def get_share_update_mail_template(self): + return self.env.ref('easy_my_coop.email_template_share_update', + False) + @api.multi def execute_operation(self): self.ensure_one() @@ -300,12 +308,10 @@ class operation_request(models.Model): # send mail to the receiver if rec.operation_type == 'transfer': - mail_template = 'easy_my_coop.email_template_share_transfer' - cert_email_template = self.env.ref(mail_template, False) + cert_email_template = self.get_share_trans_mail_template() cert_email_template.send_mail(rec.partner_id_to.id, False) self.env['subscription.register'].create(values) - mail_template = 'easy_my_coop.email_template_share_update' - cert_email_template = self.env.ref(mail_template, False) + cert_email_template = self.get_share_update_mail_template() cert_email_template.send_mail(rec.partner_id.id, False) diff --git a/easy_my_coop_loan/models/loan_issue_line.py b/easy_my_coop_loan/models/loan_issue_line.py index b0885a7..2d36581 100644 --- a/easy_my_coop_loan/models/loan_issue_line.py +++ b/easy_my_coop_loan/models/loan_issue_line.py @@ -57,10 +57,17 @@ class LoanIssueLine(models.Model): string="Company", readonly=True) + def get_loan_sub_mail_template(self): + return self.env.ref('easy_my_coop_loan.loan_subscription_confirmation', + False) + + def get_loan_pay_req_mail_template(self): + return self.env.ref('easy_my_coop_loan.loan_issue_payment_request', + False) + @api.model def create(self, vals): - mail_template = 'easy_my_coop_loan.loan_subscription_confirmation' - confirmation_mail_template = self.env.ref(mail_template, False) + confirmation_mail_template = self.get_loan_sub_mail_template() line = super(LoanIssueLine, self).create(vals) confirmation_mail_template.send_mail(line.id) @@ -79,8 +86,7 @@ class LoanIssueLine(models.Model): @api.multi def action_request_payment(self): - mail_template = 'easy_my_coop_loan.loan_issue_payment_request' - pay_req_mail_template = self.env.ref(mail_template, False) + pay_req_mail_template = self.get_loan_pay_req_mail_template() for line in self: pay_req_mail_template.send_mail(line.id) From ee2a845897caa6bb584e3af225c40201d1f058c5 Mon Sep 17 00:00:00 2001 From: houssine Date: Tue, 12 Nov 2019 12:26:12 +0100 Subject: [PATCH 4/9] [FIX] when the partner is not set but in the system --- easy_my_coop/models/coop.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/easy_my_coop/models/coop.py b/easy_my_coop/models/coop.py index 2dff4a4..6e39080 100644 --- a/easy_my_coop/models/coop.py +++ b/easy_my_coop/models/coop.py @@ -553,6 +553,9 @@ class SubscriptionRequest(models.Model): if domain: partner = partner_obj.search(domain) + if not partner.cooperator: + partner.cooperator = True + if not partner: partner = self.create_coop_partner() else: From 1fb7b50117b2d91d6cb46d5a38a896185d27dc62 Mon Sep 17 00:00:00 2001 From: houssine Date: Mon, 25 Nov 2019 11:27:56 +0100 Subject: [PATCH 6/9] [IMP] add id to allow xpath on the button --- easy_my_coop/views/res_partner_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy_my_coop/views/res_partner_view.xml b/easy_my_coop/views/res_partner_view.xml index 8fbc906..2bd57ae 100644 --- a/easy_my_coop/views/res_partner_view.xml +++ b/easy_my_coop/views/res_partner_view.xml @@ -14,7 +14,7 @@
From 9fda6bcdc160ca882f37be3a4e0345fecd11cc80 Mon Sep 17 00:00:00 2001 From: houssine Date: Mon, 25 Nov 2019 17:56:13 +0100 Subject: [PATCH 7/9] [REFACT] change xml tag to odoo --- easy_my_coop/report/easy_my_coop_report.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy_my_coop/report/easy_my_coop_report.xml b/easy_my_coop/report/easy_my_coop_report.xml index c170d3c..c138c21 100644 --- a/easy_my_coop/report/easy_my_coop_report.xml +++ b/easy_my_coop/report/easy_my_coop_report.xml @@ -1,5 +1,5 @@ - + @@ -46,4 +46,4 @@ menu="True" /> - + From 4936d43567c631b8e0bb47ec2f06b23bfdfd0361 Mon Sep 17 00:00:00 2001 From: houssine Date: Mon, 25 Nov 2019 17:57:59 +0100 Subject: [PATCH 8/9] [REFACT] put the email send in a dedicated function to allow overriding. --- easy_my_coop/models/account_invoice.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/easy_my_coop/models/account_invoice.py b/easy_my_coop/models/account_invoice.py index f5a366b..6c46ae8 100644 --- a/easy_my_coop/models/account_invoice.py +++ b/easy_my_coop/models/account_invoice.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2019 Coop IT Easy SCRL fs # Houssine Bakkali # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -98,6 +97,10 @@ class account_invoice(models.Model): return True + def send_certificate_email(self, certificate_email_template, sub_reg_line): + # we send the email with the certificate in attachment + certificate_email_template.sudo().send_mail(self.partner_id.id, False) + def set_cooperator_effective(self, effective_date): sub_register_obj = self.env['subscription.register'] share_line_obj = self.env['share.line'] @@ -115,7 +118,7 @@ class account_invoice(models.Model): sub_reg_vals['name'] = sub_reg_operation sub_reg_vals['register_number_operation'] = int(sub_reg_operation) - sub_register_obj.create(sub_reg_vals) + sub_reg_line = sub_register_obj.create(sub_reg_vals) share_line_vals = self.get_share_line_vals(line, effective_date) share_line_obj.create(share_line_vals) @@ -123,8 +126,7 @@ class account_invoice(models.Model): if line.product_id.mail_template: certificate_email_template = line.product_id.mail_template - # we send the email with the certificate in attachment - certificate_email_template.sudo().send_mail(self.partner_id.id, False) + self.send_certificate_email(certificate_email_template, sub_reg_line) if self.company_id.create_user: self.create_user(self.partner_id) From a7728f480758f1f0f52f08214b11c7e9cdca8647 Mon Sep 17 00:00:00 2001 From: houssine Date: Mon, 25 Nov 2019 18:34:16 +0100 Subject: [PATCH 9/9] [REFACT] put some code in functions to allow overriding --- easy_my_coop/models/operation_request.py | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/easy_my_coop/models/operation_request.py b/easy_my_coop/models/operation_request.py index 27594e8..1926fc3 100644 --- a/easy_my_coop/models/operation_request.py +++ b/easy_my_coop/models/operation_request.py @@ -214,6 +214,23 @@ class operation_request(models.Model): return self.env.ref('easy_my_coop.email_template_share_update', False) + def send_share_trans_mail(self, sub_register_line): + cert_email_template = self.get_share_trans_mail_template() + cert_email_template.send_mail(rec.partner_id_to.id, False) + + def send_share_update_mail(self, sub_register_line): + cert_email_template = self.get_share_update_mail_template() + cert_email_template.send_mail(rec.partner_id.id, False) + + def get_subscription_register_vals(self, effective_date): + return { + 'partner_id': self.partner_id.id, 'quantity': self.quantity, + 'share_product_id': self.share_product_id.id, + 'type': self.operation_type, + 'share_unit_price': self.share_unit_price, + 'date': effective_date, + } + @api.multi def execute_operation(self): self.ensure_one() @@ -228,13 +245,7 @@ class operation_request(models.Model): raise ValidationError(_("This operation must be approved" " before to be executed")) - values = { - 'partner_id': rec.partner_id.id, 'quantity': rec.quantity, - 'share_product_id': rec.share_product_id.id, - 'type': rec.operation_type, - 'share_unit_price': rec.share_unit_price, - 'date': effective_date, - } + values = rec.get_subscription_register_vals(effective_date) if rec.operation_type == 'sell_back': self.hand_share_over(rec.partner_id, rec.share_product_id, @@ -308,10 +319,8 @@ class operation_request(models.Model): # send mail to the receiver if rec.operation_type == 'transfer': - cert_email_template = self.get_share_trans_mail_template() - cert_email_template.send_mail(rec.partner_id_to.id, False) + self.send_share_trans_mail(sub_register_line) - self.env['subscription.register'].create(values) + sub_register_line = self.env['subscription.register'].create(values) - cert_email_template = self.get_share_update_mail_template() - cert_email_template.send_mail(rec.partner_id.id, False) + self.send_share_update_mail(sub_register_line)