# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    This module copyright (C) 2013 Therp BV (<http://therp.nl>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
    "name": "Templates for email templates",
    "version": "1.0",
    "author": "Therp BV",
    "category": 'Tools',
    'complexity': "expert",
    "description": """If an organisation's email layout is a bit more
complicated, changes can be tedious when having to do that across several email
templates. So this addon allows to define templates for mails that is referenced
by other mail templates.
This way we can put the layout parts into the template template and only content
in the other templates. Changing the layout is then only a matter of changing
the template template.


Usage:
Create an email template with the related document model 'Email Templates'. Now
most of the fields gray out and you can only edit body_text and body_html. Be
sure to use ${body_text} and ${body_html} respectively in your template
template.

Then select this newly created template templates in one of your actual
templates.""",
    'website': 'http://therp.nl',
    'images': [],
    'depends': ['email_template'],
    'data': [
        'view/email_template.xml',
    ],
    "license": 'AGPL-3',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

@@ -1896,16 +1896,1241 @@
 mplates.
+%0A%0AFor example, create a template template%0A-----%0AExample Corp logo%0AExample Corp header%0A$%7Bobject.body_text%7D %3C- this gets evaluated to the body_text of a template using this template template%0AExample Corp%0AExample street 42%0AExample city%0AExample Corp footer%0A-----%0A%0AThen in your template you write%0A%0A-----%0ADear $%7Bobject.partner_id.name%7D,%0A%0AYour order has been booked on date $%7Bobject.date%7D for a total amount of $%7Bobject.sum%7D.%0A-----%0A%0AAnd it will be evaluated to%0A%0A-----%0AExample Corp logo%0AExample Corp header%0ADear Jane Doe,%0A%0AYour order has been booked on date 04/17/2013 for a total amount of 42.%0AExample Corp%0AExample street 42%0AExample city%0AExample Corp footer%0A-----%0A%0AGiven the way evaluation works internally (body_text of the template template is evaluated two times, first with the instance of email.template of your own template, then with the object your template refers to), you can do some trickery if you know that a template template is always used with the same kind of model (that is, models that have the same field name):%0A%0AIn your template template:%0A%0A------%0ADear $%7B'$%7Bobject.name%7D'%7D, %3C-- gets evaluated to %22$%7Bobject.name%7D%22 in the first step, then to the content of object.name%0A$%7Bobject.body_html%7D%0ABest,%0AExample Corp%0A------
 %22%22%22,%0A   

add a usage example in the description