From 474016e0d0010f59244e11946a667252faf95b2b Mon Sep 17 00:00:00 2001 From: houssine Date: Thu, 6 Apr 2017 16:58:23 +0200 Subject: [PATCH] [IMP] move the sent of the capital release request in a separate function to allow overriding it by other module to exclude the sending is some use cases. --- easy_my_coop/models/coop.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/easy_my_coop/models/coop.py b/easy_my_coop/models/coop.py index 9f66963..333da6e 100644 --- a/easy_my_coop/models/coop.py +++ b/easy_my_coop/models/coop.py @@ -181,6 +181,13 @@ class subscription_request(models.Model): } return res + def send_capital_release_request(self, invoice): + invoice_email_template = self.env['mail.template'].search([('name', '=', 'Request to Release Capital - Send by Email')])[0] + + # we send the email with the capital release request in attachment + invoice_email_template.send_mail(invoice.id, True) + invoice.sent = True + def create_invoice(self, partner): # get subscription journal journal = self.env['account.journal'].search([('code','=','SUBJ')])[0] @@ -203,11 +210,7 @@ class subscription_request(models.Model): # validate the capital release request invoice.signal_workflow('invoice_open') - invoice_email_template = self.env['mail.template'].search([('name', '=', 'Request to Release Capital - Send by Email')])[0] - - # we send the email with the capital release request in attachment - invoice_email_template.send_mail(invoice.id, True) - invoice.sent = True + self.send_capital_release_request(invoice) return invoice