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.

109 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,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. -----
  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
  48. template using this template template
  49. Example Corp
  50. Example street 42
  51. Example city
  52. Example Corp footer
  53. Then in your template you write
  54. ::
  55. Dear ${object.partner_id.name},
  56. Your order has been booked on date ${object.date}
  57. for a total amount of ${object.sum}.
  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
  64. for a total amount of 42.
  65. Example Corp
  66. Example street 42
  67. Example city
  68. Example Corp footer
  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
  77. first 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. 'installable': True,
  90. }
  91. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: