You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.4 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # This module copyright (C) 2013 Therp BV (<http://therp.nl>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. {
  22. "name": "Templates for email templates",
  23. "version": "1.0",
  24. "author": "Therp BV",
  25. "category": 'Tools',
  26. 'complexity': "expert",
  27. "description": """If an organisation's email layout is a bit more
  28. complicated, changes can be tedious when having to do that across several email
  29. templates. So this addon allows to define templates for mails that is referenced
  30. by other mail templates.
  31. This way we can put the layout parts into the template template and only content
  32. in the other templates. Changing the layout is then only a matter of changing
  33. the template template.
  34. -----
  35. Usage
  36. -----
  37. Create an email template with the related document model 'Email Templates'. Now
  38. most of the fields gray out and you can only edit body_text and body_html. Be
  39. sure to use ${body_text} and ${body_html} respectively in your template
  40. template.
  41. Then select this newly created template templates in one of your actual
  42. templates.
  43. For example, create a template template
  44. ::
  45. Example Corp logo
  46. Example Corp header
  47. ${object.body_text} <- this gets evaluated to the body_text of a template using this template template
  48. Example Corp
  49. Example street 42
  50. Example city
  51. Example Corp footer
  52. Then in your template you write
  53. ::
  54. Dear ${object.partner_id.name},
  55. Your order has been booked on date ${object.date} for a total amount of ${object.sum}.
  56. And it will be evaluated to
  57. ::
  58. Example Corp logo
  59. Example Corp header
  60. Dear Jane Doe,
  61. Your order has been booked on date 04/17/2013 for a total amount of 42.
  62. Example Corp
  63. Example street 42
  64. Example city
  65. Example Corp footer
  66. Given the way evaluation works internally (body_text of the template template
  67. is evaluated two times, first with the instance of email.template of your own
  68. template, then with the object your template refers to), you can do some
  69. trickery if you know that a template template is always used with the same
  70. kind of model (that is, models that have the same field name):
  71. In your template template:
  72. ::
  73. Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the
  74. first step, then to the content of object.name
  75. ${object.body_html}
  76. Best,
  77. Example Corp
  78. """,
  79. 'website': 'http://therp.nl',
  80. 'images': [],
  81. 'depends': ['email_template'],
  82. 'data': [
  83. 'view/email_template.xml',
  84. ],
  85. "license": 'AGPL-3',
  86. 'installable': True,
  87. }
  88. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: