Browse Source

[IMP] add easy my coop flag on mail template

pull/37/head
houssine 5 years ago
committed by Rémy Taymans
parent
commit
f22d939ad7
  1. 2
      easy_my_coop/__manifest__.py
  2. 8
      easy_my_coop/data/mail_template_data.xml
  3. 1
      easy_my_coop/models/__init__.py
  4. 22
      easy_my_coop/models/mail_template.py
  5. 1
      easy_my_coop/views/email_template_view.xml
  6. 2
      easy_my_coop_loan/data/mail_template_data.xml
  7. 1
      easy_my_coop_loan/models/__init__.py
  8. 15
      easy_my_coop_loan/models/mail_template.py
  9. 6
      easy_my_coop_taxshelter_report/data/mail_template_data.xml
  10. 16
      easy_my_coop_taxshelter_report/models/mail_template.py

2
easy_my_coop/__manifest__.py

@ -5,7 +5,7 @@
{ {
'name': 'Easy My Coop', 'name': 'Easy My Coop',
'version': '12.0.2.0.2',
'version': '12.0.3.0.1',
'depends': [ 'depends': [
'base', 'base',
'web', 'web',

8
easy_my_coop/data/mail_template_data.xml

@ -15,6 +15,7 @@
<field name="report_template" ref="action_cooperator_invoices"/> <field name="report_template" ref="action_cooperator_invoices"/>
<field name="report_name">${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''}</field> <field name="report_name">${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''}</field>
<field name="lang">${object.partner_id.lang}</field> <field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
@ -65,6 +66,7 @@
<field name="model_id" ref="model_subscription_request"/> <field name="model_id" ref="model_subscription_request"/>
<field name="auto_delete" eval="True"/> <field name="auto_delete" eval="True"/>
<field name="lang">${object.lang}</field> <field name="lang">${object.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
@ -117,6 +119,7 @@
<field name="model_id" ref="model_subscription_request"/> <field name="model_id" ref="model_subscription_request"/>
<field name="auto_delete" eval="True"/> <field name="auto_delete" eval="True"/>
<field name="lang">${object.lang}</field> <field name="lang">${object.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
@ -166,7 +169,6 @@
<field name="name">Payment Received Confirmation - Send By Email</field> <field name="name">Payment Received Confirmation - Send By Email</field>
<field name="email_from">${(object.company_id.coop_email_contact or object.user_id.email)|safe}</field> <field name="email_from">${(object.company_id.coop_email_contact or object.user_id.email)|safe}</field>
<field name="subject">Payment Received Confirmation</field> <field name="subject">Payment Received Confirmation</field>
<!-- <field name="email_recipients">${object.partner_id.id}</field> -->
<field name="partner_to">${object.id}</field> <field name="partner_to">${object.id}</field>
<field name="reply_to">${(object.company_id.coop_email_contact or object.user_id.email)|safe}</field> <field name="reply_to">${(object.company_id.coop_email_contact or object.user_id.email)|safe}</field>
<field name="model_id" ref="model_res_partner"/> <field name="model_id" ref="model_res_partner"/>
@ -174,6 +176,7 @@
<field name="report_template" ref="action_cooperator_report_certificat"/> <field name="report_template" ref="action_cooperator_report_certificat"/>
<field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field> <field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field>
<field name="lang">${object.lang}</field> <field name="lang">${object.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
@ -228,6 +231,7 @@
<field name="report_template" ref="action_cooperator_report_certificat"/> <field name="report_template" ref="action_cooperator_report_certificat"/>
<field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field> <field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field>
<field name="lang">${object.lang}</field> <field name="lang">${object.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
@ -282,6 +286,7 @@
<field name="report_template" ref="action_cooperator_report_certificat"/> <field name="report_template" ref="action_cooperator_report_certificat"/>
<field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field> <field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field>
<field name="lang">${object.lang}</field> <field name="lang">${object.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
@ -336,6 +341,7 @@
<field name="report_template" ref="action_cooperator_report_certificat"/> <field name="report_template" ref="action_cooperator_report_certificat"/>
<field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field> <field name="report_name">Certificat ${(object.cooperator_register_number or '')}</field>
<field name="lang">${object.lang}</field> <field name="lang">${object.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">

1
easy_my_coop/models/__init__.py

@ -6,3 +6,4 @@ from . import account_invoice
from . import company from . import company
from . import res_partner_bank from . import res_partner_bank
from . import account_journal from . import account_journal
from . import mail_template

22
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")

1
easy_my_coop/views/email_template_view.xml

@ -7,6 +7,7 @@
<field name="res_model">mail.template</field> <field name="res_model">mail.template</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">form,tree</field> <field name="view_mode">form,tree</field>
<field name="domain">[('easy_my_coop','=',True)]</field>
<field name="view_id" ref="mail.email_template_tree" /> <field name="view_id" ref="mail.email_template_tree" />
<field name="search_view_id" ref="mail.view_email_template_search" /> <field name="search_view_id" ref="mail.view_email_template_search" />
</record> </record>

2
easy_my_coop_loan/data/mail_template_data.xml

@ -13,6 +13,7 @@
<field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/> <field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/>
<field name="auto_delete" eval="True"/> <field name="auto_delete" eval="True"/>
<field name="lang">${object.partner_id.lang}</field> <field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
@ -65,6 +66,7 @@
<field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/> <field name="model_id" ref="easy_my_coop_loan.model_loan_issue_line"/>
<field name="auto_delete" eval="True"/> <field name="auto_delete" eval="True"/>
<field name="lang">${object.partner_id.lang}</field> <field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">

1
easy_my_coop_loan/models/__init__.py

@ -2,3 +2,4 @@ from . import loan
from . import loan_issue_line from . import loan_issue_line
from . import interest_line from . import interest_line
from . import partner from . import partner
from . import mail_template

15
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

6
easy_my_coop_taxshelter_report/data/mail_template_data.xml

@ -1,4 +1,4 @@
<openerp>
<odoo>
<!-- Mail template are declared in a NOUPDATE block <!-- Mail template are declared in a NOUPDATE block
so users can freely customize/delete them --> so users can freely customize/delete them -->
<data noupdate="1"> <data noupdate="1">
@ -11,6 +11,7 @@
<field name="model_id" ref="model_tax_shelter_certificate"/> <field name="model_id" ref="model_tax_shelter_certificate"/>
<field name="auto_delete" eval="True"/> <field name="auto_delete" eval="True"/>
<field name="lang">${object.partner_id.lang}</field> <field name="lang">${object.partner_id.lang}</field>
<field name="easy_my_coop" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
<p>Hello ${object.partner_id.name},</p> <p>Hello ${object.partner_id.name},</p>
@ -51,6 +52,5 @@
</div> </div>
]]></field> ]]></field>
</record> </record>
</data> </data>
</openerp>
</odoo>

16
easy_my_coop_taxshelter_report/models/mail_template.py

@ -1,11 +1,18 @@
# -*- 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" _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 @api.multi
def send_mail_with_multiple_attachments(self, res_id, def send_mail_with_multiple_attachments(self, res_id,
additional_attachments, additional_attachments,
@ -24,7 +31,8 @@ class MailTemplate(models.Model):
""" """
self.ensure_one() self.ensure_one()
Mail = self.env['mail.mail'] 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 # create a mail_mail based on values, without attachments
values = self.generate_email(res_id) values = self.generate_email(res_id)

Loading…
Cancel
Save