Browse Source

[IMP] improve the way the mails are sent.

pull/1/head
houssine 7 years ago
parent
commit
a3f29a8a87
  1. 17
      easy_my_coop_taxshelter_report/models/tax_shelter_declaration.py

17
easy_my_coop_taxshelter_report/models/tax_shelter_declaration.py

@ -149,12 +149,15 @@ class TaxShelterCertificate(models.Model):
# TODO # TODO
return attachments return attachments
@api.one
@api.multi
def send_certificates(self): def send_certificates(self):
attachments = self.generate_certificates_report()
tax_shelter_mail_template = self.env.ref('easy_my_coop_taxshelter_report.email_template_tax_shelter_certificate', False)
for certificate in self:
attachments = certificate.generate_certificates_report()
if len(attachments) > 0: if len(attachments) > 0:
confirmation_mail_template = self.env['mail.template'].search([('name', '=', 'Tax Shelter Certificate - Send By Email')])[0]
confirmation_mail_template.send_mail_with_multiple_attachments(self.id, attachments,True)
tax_shelter_mail_template.send_mail_with_multiple_attachments(certificate.id, attachments,True)
certificate.state = 'sent'
self.env.cr.commit()
@api.multi @api.multi
def print_subscription_certificate(self): def print_subscription_certificate(self):
@ -168,7 +171,6 @@ class TaxShelterCertificate(models.Model):
@api.multi @api.multi
def _compute_amounts(self): def _compute_amounts(self):
for certificate in self: for certificate in self:
total_amount_previously_subscribed = 0 total_amount_previously_subscribed = 0
total_amount_subscribed = 0 total_amount_subscribed = 0
@ -208,10 +210,7 @@ class TaxShelterCertificate(models.Model):
@api.model @api.model
def batch_send_tax_shelter_certificate(self): def batch_send_tax_shelter_certificate(self):
certificates = self.search([('state','=','validated')],limit=80) certificates = self.search([('state','=','validated')],limit=80)
for certificate in certificates:
certificate.send_certificates()
certificate.state = 'sent'
self.env.cr.commit()
certificates.send_certificates()
class TaxShelterCertificateLine(models.Model): class TaxShelterCertificateLine(models.Model):
_name= "certificate.line" _name= "certificate.line"

Loading…
Cancel
Save