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.

96 lines
3.3 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # This module copyright (C) 2012 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. Usage:
  35. Create an email template with the related document model 'Email Templates'. Now
  36. most of the fields gray out and you can only edit body_text and body_html. Be
  37. sure to use ${body_text} and ${body_html} respectively in your template
  38. template.
  39. Then select this newly created template templates in one of your actual
  40. templates.
  41. For example, create a template template
  42. -----
  43. Example Corp logo
  44. Example Corp header
  45. ${object.body_text} <- this gets evaluated to the body_text of a template using this template template
  46. Example Corp
  47. Example street 42
  48. Example city
  49. Example Corp footer
  50. -----
  51. Then in your template you write
  52. -----
  53. Dear ${object.partner_id.name},
  54. Your order has been booked on date ${object.date} for a total amount of ${object.sum}.
  55. -----
  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. -----
  67. Given 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):
  68. In your template template:
  69. ------
  70. Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the first step, then to the content of object.name
  71. ${object.body_html}
  72. Best,
  73. Example Corp
  74. ------""",
  75. 'website': 'http://therp.nl',
  76. 'images': [],
  77. 'depends': ['email_template'],
  78. 'data': [
  79. 'view/email_template.xml',
  80. ],
  81. "license": 'AGPL-3',
  82. }
  83. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: