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/account_invoice.py b/easy_my_coop/models/account_invoice.py
index f3731fd..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).
@@ -46,8 +45,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)
@@ -96,18 +97,20 @@ 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']
- 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,
@@ -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)
diff --git a/easy_my_coop/models/coop.py b/easy_my_coop/models/coop.py
index a747f31..6e39080 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
@@ -551,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:
diff --git a/easy_my_coop/models/mail_template.py b/easy_my_coop/models/mail_template.py
new file mode 100644
index 0000000..f346a21
--- /dev/null
+++ b/easy_my_coop/models/mail_template.py
@@ -0,0 +1,12 @@
+from odoo import models, fields
+
+
+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/models/operation_request.py b/easy_my_coop/models/operation_request.py
index f4b5ded..1926fc3 100644
--- a/easy_my_coop/models/operation_request.py
+++ b/easy_my_coop/models/operation_request.py
@@ -206,6 +206,31 @@ 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)
+
+ 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()
@@ -220,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,
@@ -300,12 +319,8 @@ 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.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)
- mail_template = 'easy_my_coop.email_template_share_update'
- cert_email_template = self.env.ref(mail_template, False)
- cert_email_template.send_mail(rec.partner_id.id, False)
+ self.send_share_update_mail(sub_register_line)
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"
/>
-
+
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.templateformform,tree
+ [('easy_my_coop','=',True)]
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 @@
-
diff --git a/easy_my_coop_loan/data/mail_template_data.xml b/easy_my_coop_loan/data/mail_template_data.xml
index eb67939..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}
@@ -13,6 +12,7 @@
${object.partner_id.lang}
+
@@ -65,6 +65,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/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)
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..12138c7
--- /dev/null
+++ b/easy_my_coop_loan/models/mail_template.py
@@ -0,0 +1,10 @@
+from odoo import models
+
+
+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..4d44e0a 100644
--- a/easy_my_coop_taxshelter_report/models/mail_template.py
+++ b/easy_my_coop_taxshelter_report/models/mail_template.py
@@ -1,18 +1,21 @@
-# -*- coding: utf-8 -*-
-from openerp import api, models
+from odoo import api, models
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 +27,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)