andreparames
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 425 additions and 0 deletions
-
77email_template_configurator/README.rst
-
1email_template_configurator/__init__.py
-
21email_template_configurator/__openerp__.py
-
107email_template_configurator/i18n/fr.po
-
2email_template_configurator/models/__init__.py
-
22email_template_configurator/models/email_template.py
-
19email_template_configurator/models/email_template_placeholder.py
-
33email_template_configurator/security/email_template_placeholder.xml
-
1email_template_configurator/tests/__init__.py
-
36email_template_configurator/tests/test_configurator.py
-
30email_template_configurator/views/email_template.xml
-
68email_template_configurator/views/email_template_placeholder.xml
-
1setup/email_template_configurator/odoo_addons/__init__.py
-
1setup/email_template_configurator/odoo_addons/email_template_configurator
-
6setup/email_template_configurator/setup.py
@ -0,0 +1,77 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png |
|||
:target: https://www.gnu.org/licenses/agpl |
|||
:alt: License: AGPL-3 |
|||
|
|||
=========================== |
|||
email_template_configurator |
|||
=========================== |
|||
|
|||
This module implements a simpler interface for the email template dynamic |
|||
fields. A configurator allows the creation of predefined named replacement |
|||
strings, which can then be selected in the template. |
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
To configure this module, you need to: |
|||
|
|||
#. Add your user to the "Template Placeholders Manager" group |
|||
|
|||
#. Go to Settings → Technical → Email → Template Placeholders to create new |
|||
predefined placeholders |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, you need to: |
|||
|
|||
#. Create a new template and go to the Configured Placeholders tab |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/111/8.0 |
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues |
|||
<https://github.com/OCA/crm/issues>`_. In case of trouble, please |
|||
check there if your issue has already been reported. If you spotted it first, |
|||
help us smash it by providing detailed and welcomed feedback. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Images |
|||
------ |
|||
|
|||
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_. |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* André Paramés Pereira (ACSONE) <github@andreparames.com> |
|||
|
|||
Do not contact contributors directly about support or help with technical issues. |
|||
|
|||
Funders |
|||
------- |
|||
|
|||
The development of this module has been financially supported by: |
|||
|
|||
* ACSONE SA/NV |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
OCA, or the Odoo Community Association, is a nonprofit organization whose |
|||
mission is to support the collaborative development of Odoo features and |
|||
promote its widespread use. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1 @@ |
|||
from . import models |
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2018 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
{ |
|||
'name': 'Email Template Configurator', |
|||
'description': """ |
|||
Simplifies use of placeholders in email templates""", |
|||
'version': '8.0.1.0.0', |
|||
'license': 'AGPL-3', |
|||
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', |
|||
'website': 'https://github.com/OCA/crm', |
|||
'depends': [ |
|||
'email_template', |
|||
], |
|||
'data': [ |
|||
'security/email_template_placeholder.xml', |
|||
'views/email_template_placeholder.xml', |
|||
'views/email_template.xml', |
|||
], |
|||
} |
@ -0,0 +1,107 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * email_template_configurator |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 8.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2018-12-28 18:59+0000\n" |
|||
"PO-Revision-Date: 2018-12-28 18:59+0000\n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,active:0 |
|||
msgid "Active" |
|||
msgstr "Actif" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,create_uid:0 |
|||
msgid "Created by" |
|||
msgstr "Créé par" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,create_date:0 |
|||
msgid "Created on" |
|||
msgstr "Créé le" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,display_name:0 |
|||
msgid "Display Name" |
|||
msgstr "Nom affiché" |
|||
|
|||
#. module: email_template_configurator |
|||
#: model:ir.model,name:email_template_configurator.model_email_template_placeholder |
|||
msgid "Email Template Placeholder" |
|||
msgstr "Champ de fusion de modèle de courriel" |
|||
|
|||
#. module: email_template_configurator |
|||
#: model:ir.model,name:email_template_configurator.model_email_template |
|||
msgid "Email Templates" |
|||
msgstr "Modèles de courriels" |
|||
|
|||
#. module: email_template_configurator |
|||
#: view:email.template.placeholder:email_template_configurator.email_template_placeholder_search_view |
|||
msgid "Group by..." |
|||
msgstr "Grouper par..." |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,id:0 |
|||
msgid "ID" |
|||
msgstr "ID" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,__last_update:0 |
|||
msgid "Last Modified on" |
|||
msgstr "Dernière modification le" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,write_uid:0 |
|||
msgid "Last Updated by" |
|||
msgstr "Dernière modification par" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template.placeholder,write_date:0 |
|||
msgid "Last Updated on" |
|||
msgstr "Dernière mise à jour le" |
|||
|
|||
#. module: email_template_configurator |
|||
#: view:email.template.placeholder:email_template_configurator.email_template_placeholder_search_view |
|||
#: field:email.template.placeholder,model_id:0 |
|||
msgid "Model" |
|||
msgstr "Modèle" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template,placeholder_id:0 |
|||
#: field:email.template.placeholder,name:0 |
|||
msgid "Placeholder" |
|||
msgstr "Champ de fusion" |
|||
|
|||
#. module: email_template_configurator |
|||
#: field:email.template,placeholder_value:0 |
|||
#: field:email.template.placeholder,placeholder:0 |
|||
msgid "Placeholder value" |
|||
msgstr "Valeur du champ de fusion" |
|||
|
|||
#. module: email_template_configurator |
|||
#: help:email.template,placeholder_value:0 |
|||
msgid "Placeholder value to copy-paste in the desired template field" |
|||
msgstr "Valeur du champ de fusion à copier-coller dans le champ de modèle désiré" |
|||
|
|||
#. module: email_template_configurator |
|||
#: model:res.groups,name:email_template_configurator.group_email_template_placeholders_manager |
|||
msgid "Placeholders Manager" |
|||
msgstr "Gestionnaire de champs de fusion" |
|||
|
|||
#. module: email_template_configurator |
|||
#: view:email.template:email_template_configurator.email_template_form_view |
|||
#: model:ir.actions.act_window,name:email_template_configurator.email_template_placeholder_act_window |
|||
#: model:ir.ui.menu,name:email_template_configurator.email_template_placeholder_menu |
|||
msgid "Predefined Placeholders" |
|||
msgstr "Champs de fusion prédéfinis" |
|||
|
@ -0,0 +1,2 @@ |
|||
from . import email_template_placeholder |
|||
from . import email_template |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2018 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import api, fields, models |
|||
|
|||
|
|||
class EmailTemplate(models.Model): |
|||
|
|||
_inherit = 'email.template' |
|||
|
|||
# Fake field for auto-completing placeholder |
|||
placeholder_id = fields.Many2one( |
|||
'email.template.placeholder', string="Placeholder") |
|||
placeholder_value = fields.Char( |
|||
help='Placeholder value to copy-paste in the desired template field') |
|||
|
|||
@api.onchange('placeholder_id') |
|||
def _onchange_placeholder_id(self): |
|||
for tmpl in self: |
|||
if tmpl.placeholder_id: |
|||
tmpl.placeholder_value = tmpl.placeholder_id.placeholder |
@ -0,0 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2018 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import fields, models |
|||
|
|||
|
|||
class EmailTemplatePlaceholder(models.Model): |
|||
|
|||
_name = 'email.template.placeholder' |
|||
_description = 'Email Template Placeholder' |
|||
|
|||
name = fields.Char(string='Placeholder', required=True) |
|||
model_id = fields.Many2one( |
|||
'ir.model', string='Model', required=True) |
|||
placeholder = fields.Char( |
|||
string='Placeholder value', |
|||
required=True, default='${object.}') |
|||
active = fields.Boolean(default=True) |
@ -0,0 +1,33 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2018 ACSONE SA/NV |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="group_email_template_placeholders_manager" model="res.groups"> |
|||
<field name="name">Placeholders Manager</field> |
|||
</record> |
|||
|
|||
<record model="ir.model.access" id="email_template_placeholder_access_user"> |
|||
<field name="name">email.template.placeholder access user</field> |
|||
<field name="model_id" ref="model_email_template_placeholder"/> |
|||
<field name="group_id" ref="base.group_user"/> |
|||
<field name="perm_read" eval="1"/> |
|||
<field name="perm_create" eval="0"/> |
|||
<field name="perm_write" eval="0"/> |
|||
<field name="perm_unlink" eval="0"/> |
|||
</record> |
|||
|
|||
<record model="ir.model.access" id="email_template_placeholder_access_manager"> |
|||
<field name="name">email.template.placeholder access manager</field> |
|||
<field name="model_id" ref="model_email_template_placeholder"/> |
|||
<field name="group_id" ref="group_email_template_placeholders_manager"/> |
|||
<field name="perm_read" eval="1"/> |
|||
<field name="perm_create" eval="1"/> |
|||
<field name="perm_write" eval="1"/> |
|||
<field name="perm_unlink" eval="1"/> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1 @@ |
|||
from . import test_configurator |
@ -0,0 +1,36 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2018 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp.tests import common |
|||
|
|||
|
|||
class TestConfigurator(common.TransactionCase): |
|||
|
|||
def test_configurator(self): |
|||
placeholders_obj = self.env['email.template.placeholder'] |
|||
templates_obj = self.env['email.template'] |
|||
invoice_model = self.env['ir.model'].search([ |
|||
('model', '=', 'res.partner'), |
|||
]) |
|||
placeholders_vals = [ |
|||
{ |
|||
'name': 'Invoice partner name', |
|||
'model_id': invoice_model.id, |
|||
'placeholder': '${object.partner_id.name}', |
|||
}, |
|||
{ |
|||
'name': 'Invoice partner vat', |
|||
'model_id': invoice_model.id, |
|||
'placeholder': '${object.partner_id.vat}', |
|||
}, |
|||
] |
|||
for vals in placeholders_vals: |
|||
placeholder = placeholders_obj.create(vals) |
|||
res = templates_obj.onchange({ |
|||
'placeholder_id': placeholder.id, |
|||
'placeholder_value': False, |
|||
}, 'placeholder_id', { |
|||
'placeholder_id': "1", |
|||
})['value'] |
|||
self.assertEqual(res['placeholder_value'], vals['placeholder']) |
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2018 ACSONE SA/NV |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<openerp> |
|||
<data> |
|||
|
|||
<record model="ir.ui.view" id="email_template_form_view"> |
|||
<field name="name">email.template.form (in email_template_configurator)</field> |
|||
<field name="model">email.template</field> |
|||
<field name="inherit_id" ref="email_template.email_template_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//page[.//field[@name='model_object_field']]" position="attributes"> |
|||
<attribute name="groups" translation="off">email_template_configurator.group_email_template_placeholders_manager</attribute> |
|||
</xpath> |
|||
<xpath expr="//page[.//field[@name='model_object_field']]" position="after"> |
|||
<page name="configured_placeholders" string="Predefined Placeholders"> |
|||
<group> |
|||
<field name="placeholder_id" |
|||
domain="[('model_id','=',model_id)]" |
|||
options="{'no_quick_create':True,'no_create_edit':True}"/> |
|||
<field name="placeholder_value"/> |
|||
</group> |
|||
</page> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,68 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2018 ACSONE SA/NV |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<openerp> |
|||
<data> |
|||
|
|||
<record model="ir.ui.view" id="email_template_placeholder_form_view"> |
|||
<field name="name">email.template.placeholder.form (in email_template_configurator)</field> |
|||
<field name="model">email.template.placeholder</field> |
|||
<field name="arch" type="xml"> |
|||
<form> |
|||
<sheet> |
|||
<group> |
|||
<field name="name"/> |
|||
<field name="active"/> |
|||
</group> |
|||
<group> |
|||
<field name="model_id"/> |
|||
<field name="placeholder"/> |
|||
</group> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record model="ir.ui.view" id="email_template_placeholder_search_view"> |
|||
<field name="name">email.template.placeholder.search (in email_template_configurator)</field> |
|||
<field name="model">email.template.placeholder</field> |
|||
<field name="arch" type="xml"> |
|||
<search> |
|||
<field name="name"/> |
|||
<field name="model_id"/> |
|||
<group string="Group by..."> |
|||
<filter string="Model" domain="[]" context="{'group_by':'model_id'}" icon="terp-accessories-archiver"/> |
|||
</group> |
|||
</search> |
|||
</field> |
|||
</record> |
|||
|
|||
<record model="ir.ui.view" id="email_template_placeholder_tree_view"> |
|||
<field name="name">email.template.placeholder.tree (in email_template_configurator)</field> |
|||
<field name="model">email.template.placeholder</field> |
|||
<field name="arch" type="xml"> |
|||
<tree> |
|||
<field name="name"/> |
|||
<field name="model_id"/> |
|||
<field name="placeholder"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record model="ir.actions.act_window" id="email_template_placeholder_act_window"> |
|||
<field name="name">Predefined Placeholders</field> |
|||
<field name="res_model">email.template.placeholder</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="domain">[]</field> |
|||
<field name="context">{}</field> |
|||
</record> |
|||
|
|||
<record model="ir.ui.menu" id="email_template_placeholder_menu"> |
|||
<field name="name">Predefined Placeholders</field> |
|||
<field name="parent_id" ref="base.menu_email"/> |
|||
<field name="action" ref="email_template_placeholder_act_window"/> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1 @@ |
|||
__import__('pkg_resources').declare_namespace(__name__) |
@ -0,0 +1 @@ |
|||
../../../email_template_configurator |
@ -0,0 +1,6 @@ |
|||
import setuptools |
|||
|
|||
setuptools.setup( |
|||
setup_requires=['setuptools-odoo'], |
|||
odoo_addon=True, |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue