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.

103 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,Odoo Community Association (OCA)",
  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
  30. referenced by other mail templates.
  31. This way we can put the layout parts into the template template and only
  32. content in the other templates. Changing the layout is then only a matter of
  33. changing 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
  46. this template template
  47. Example Corp
  48. Example street 42
  49. Example city
  50. Example Corp footer
  51. -----
  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
  56. ${object.sum}.
  57. -----
  58. And it will be evaluated to
  59. -----
  60. Example Corp logo
  61. Example Corp header
  62. Dear Jane Doe,
  63. Your order has been booked on date 04/17/2013 for a total amount of 42.
  64. Example Corp
  65. Example street 42
  66. Example city
  67. Example Corp footer
  68. -----
  69. Given the way evaluation works internally (body_text of the template template
  70. is evaluated two times, first with the instance of email.template of your own
  71. template, then with the object your template refers to), you can do some
  72. trickery if you know that a template template is always used with the same kind
  73. of model (that is, models that have the same field name):
  74. In your template template:
  75. ------
  76. Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the first
  77. step, then to the content of object.name
  78. ${object.body_html}
  79. Best,
  80. Example Corp
  81. ------""",
  82. 'website': 'http://therp.nl',
  83. 'images': [],
  84. 'depends': ['email_template'],
  85. 'data': [
  86. 'view/email_template.xml',
  87. ],
  88. "license": 'AGPL-3',
  89. }
  90. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: