Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0] [MIG] mail_layout_preview: Migration to 17.0 #1371

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions mail_layout_preview/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
============
Mail Preview
============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4b096426f65610ad76b1408c5d42186b2e65076726ffd214653362f77bd00fe2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/17.0/mail_layout_preview
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_layout_preview
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

The purpose of this module is to help development of email templates
allowing to render the full layout preview of each of them.

Odoo already allows you do preview emails but they are wrapped into Odoo
backend theme.

NOTE: to make work properly your emails it's strongly recommended to use
mail_inline_css to include all styles in the body of the email.

**Table of contents**

.. contents::
:local:

Usage
=====

- Go to a template and click on the preview button
- Select desired params and click on "Full layout preview" link
- You'll get to the preview

As a developer, you can see a list of all templates for a model by going
to:

/email-preview/$model.name

You'll get a list of all the templates. Follow the instructions there on
how to use the links.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_layout_preview%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Camptocamp SA

Contributors
------------

- Simone Orsi <simahawk@gmail.com>
- Phuc Tran Thanh <phuc@trobz.com>
- Son Ho <sonhd@trobz.com>

Other credits
-------------

The development and migration of this module from 15.0 to 16.0 has been
financially supported by:

- Camptocamp

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/social <https://github.com/OCA/social/tree/17.0/mail_layout_preview>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions mail_layout_preview/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import wizard
15 changes: 15 additions & 0 deletions mail_layout_preview/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Mail Preview",
"summary": """
Preview email templates in the browser""",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Camptocamp SA,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"depends": ["mail"],
"data": ["templates/email_preview.xml", "wizard/email_template_preview.xml"],
"development_status": "Beta",
}
1 change: 1 addition & 0 deletions mail_layout_preview/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import layout_preview
46 changes: 46 additions & 0 deletions mail_layout_preview/controllers/layout_preview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2020 Simone Orsi - Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import http
from odoo.http import request


class Preview(http.Controller):
_list_template = "mail_layout_preview.email_templates_list"

@http.route(
["/email-preview/<string:model>"], type="http", auth="user", website=True
)
def template_list(self, model, **kw):
env = request.env
templates = env["mail.template"].search([("model_id.model", "=", model)])
xids = templates.get_external_id()
return request.render(
self._list_template, {"model": model, "templates": templates, "xids": xids}
)

@http.route(
["/email-preview/<string:model>/<string:templ_id>/<int:rec_id>"],
type="http",
auth="user",
website=True,
)
def preview(self, model, templ_id, rec_id, **kw):
"""Render an email template to verify look and feel.

Provide model, record id and an email template to render.

Example for event registration email:

/email-preview/event.registration/event.event_subscription/5
"""
env = request.env
record = env[model].browse(rec_id)
if templ_id.isdigit():
# got an ID
template = env["mail.template"].browse(int(templ_id))
else:
# got a XID
template = env.ref(templ_id.strip())

Check warning on line 44 in mail_layout_preview/controllers/layout_preview.py

View check run for this annotation

Codecov / codecov/patch

mail_layout_preview/controllers/layout_preview.py#L44

Added line #L44 was not covered by tests
result = template._generate_template([record.id], ["body_html"])
return request.make_response(result[record.id]["body_html"])
94 changes: 94 additions & 0 deletions mail_layout_preview/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_layout_preview
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-09 17:37+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "<strong>Link:</strong>"
msgstr "<strong>Enlace:</strong>"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "<strong>Name:</strong>"
msgstr "<strong>Nombre:</strong>"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "<strong>XMLID:</strong>"
msgstr "<strong>XMLID:</strong>"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Copy the link"
msgstr "Copiar el enlace"

#. module: mail_layout_preview
#: model:ir.model,name:mail_layout_preview.model_mail_template_preview
msgid "Email Template Preview"
msgstr "Previsualización plantilla Email"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Email templates for:"
msgstr "Plantillas de correo electrónico para:"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Find your template"
msgstr "Encuentre su plantilla"

#. module: mail_layout_preview
#: model:ir.model.fields,field_description:mail_layout_preview.field_mail_template_preview__layout_preview_url
msgid "Full layout preview"
msgstr "Vista previa completa del diseño"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Here you find all the template for the given model."
msgstr "Aquí encontrará todas las plantillas del modelo en cuestión."

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Load it"
msgstr "Cárgalo"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "No template found."
msgstr "No se ha encontrado ninguna plantilla."

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid ""
"Paste into the address bar and change the record ID (the last value in the URL).\n"
" <br/>If you don't know the ID of the record, just browse to the record via odoo interface and check its ID in the address bar `#id=XXX`."
msgstr ""
"Pegue en la barra de direcciones y cambie el ID del registro (el último "
"valor en la URL).\n"
" <br/>Si no conoce el ID del registro, simplemente busque el "
"registro a través de la interfaz de odoo y verifique su ID en la barra de "
"direcciones `#id=XXX`."

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Preview"
msgstr "Previsualización"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "View in backend"
msgstr "Ver en el servidor"
94 changes: 94 additions & 0 deletions mail_layout_preview/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_layout_preview
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-07 12:35+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "<strong>Link:</strong>"
msgstr "<strong>Collegamento:</strong>"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "<strong>Name:</strong>"
msgstr "<strong>Nome:</strong>"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "<strong>XMLID:</strong>"
msgstr "<strong>XMLID:</strong>"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Copy the link"
msgstr "Copia collegamento"

#. module: mail_layout_preview
#: model:ir.model,name:mail_layout_preview.model_mail_template_preview
msgid "Email Template Preview"
msgstr "Anteprima modello e-mail"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Email templates for:"
msgstr "Modello e-mail per:"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Find your template"
msgstr "Trova il tuo modello"

#. module: mail_layout_preview
#: model:ir.model.fields,field_description:mail_layout_preview.field_mail_template_preview__layout_preview_url
msgid "Full layout preview"
msgstr "Anteprima impaginazione piena"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Here you find all the template for the given model."
msgstr "Qui si trovano tutti i modelli per il tipo dato."

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Load it"
msgstr "Caricalo"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "No template found."
msgstr "Nessun modello trovato."

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid ""
"Paste into the address bar and change the record ID (the last value in the URL).\n"
" <br/>If you don't know the ID of the record, just browse to the record via odoo interface and check its ID in the address bar `#id=XXX`."
msgstr ""
"Incollare nella barra indirizzo e modificare l'ID record (l'ultimo valore "
"nell'URL).\n"
" <br/>Se non si conosce l'ID del record, navigare fino al "
"record con l'interfaccia Odoo e controllare l'ID nella "
"barraindirizzo`#id=XXX`."

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "Preview"
msgstr "Anteprima"

#. module: mail_layout_preview
#: model_terms:ir.ui.view,arch_db:mail_layout_preview.email_templates_list
msgid "View in backend"
msgstr "Vedi nel backend"
Loading
Loading