Skip to content

Commit ff8b590

Browse files
committed
[5383][ADD] mail_layout_force
1 parent 5a307d0 commit ff8b590

27 files changed

Lines changed: 1540 additions & 0 deletions

mail_layout_force/README.rst

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
=================
2+
Mail Layout Force
3+
=================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:75c9b356ed3fb4496d5dedee1dfa1599e2cba7e8b8558728c0c1dba22a87b1c2
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
20+
:target: https://github.com/OCA/social/tree/16.0/mail_layout_force
21+
:alt: OCA/social
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_layout_force
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Odoo will add a default email layout on most commercial communications.
32+
33+
The email layout is a ``QWeb`` view that ends up wrapping the message body
34+
when sending an email. It usually displays the related document reference,
35+
the company logo, and a small footer saying "Powered by Odoo".
36+
37+
There are notably two main layouts used in Odoo, and the user can't control when
38+
they're used, as it's hardcoded into the different applications.
39+
40+
* ``mail.message_notification_email``
41+
* ``mail.mail_notification_light``
42+
* ``mail.mail_notification_paynow``
43+
44+
This module allows to force a specific layout for a given ``email.template``,
45+
effectively overwritting the one hardcoded by Odoo. Additionally, it enables
46+
forcing a custom layout for emails that do not use an existing ``email.template``
47+
record (e.g., when sending an email from the chatter).
48+
49+
This allows you to fully customize the way Odoo emails are rendered and sent
50+
to your customers.
51+
52+
**Table of contents**
53+
54+
.. contents::
55+
:local:
56+
57+
Configuration
58+
=============
59+
60+
#. Go to Settings > Technical > Emails > Templates
61+
#. Open the desired ``email.template`` record.
62+
#. In Advanced Parameters tab, find the Force Layout field.
63+
64+
You can leave it empty to use the default email layout (chosen by Odoo).
65+
You can force a custom email layout of your own.
66+
You can use the *Mail: No-Layout notification template* to prevent Odoo
67+
from adding a layout.
68+
69+
To configure a custom layout of your own, some technical knowledge is needed.
70+
You can see how the existing layouts are defined for details or inspiration:
71+
72+
* ``mail.mail_notification_light``
73+
* ``mail.mail_notification_paynow``
74+
* ``mail.mail_notification_borders``
75+
76+
To force a new custom layout for emails that do not use an existing ``email.template``
77+
record (e.g., emails sent from the chatter):
78+
79+
#. Go to Settings > Technical > User Interface > Views.
80+
#. Copy the current layout (e.g., mail.message_notification_email) to create a new one, and remove any parts you don’t need.
81+
#. Open the layout that you want to swap with a substitute. Then, under the Layout Mapping tab:
82+
* Set ``Substitute Layout`` to the new custom layout you created.
83+
* Set ``Models`` if you want to apply the replacement only to specific models. If left empty,
84+
the email layout will be replaced for all models.
85+
86+
Bug Tracker
87+
===========
88+
89+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
90+
In case of trouble, please check there if your issue has already been reported.
91+
If you spotted it first, help us to smash it by providing a detailed and welcomed
92+
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_layout_force%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
93+
94+
Do not contact contributors directly about support or help with technical issues.
95+
96+
Credits
97+
=======
98+
99+
Authors
100+
~~~~~~~
101+
102+
* Camptocamp
103+
104+
Contributors
105+
~~~~~~~~~~~~
106+
107+
* `Camptocamp <https://www.camptocamp.com>`_
108+
109+
* Iván Todorovich <ivan.todorovich@camptocamp.com>
110+
* Abraham Anes <abrahamanes@gmail.com>
111+
* `Quartile <https://www.quartile.co>`_
112+
113+
* Aung Ko Ko Lin
114+
* Yoshi Tashiro
115+
116+
Maintainers
117+
~~~~~~~~~~~
118+
119+
This module is maintained by the OCA.
120+
121+
.. image:: https://odoo-community.org/logo.png
122+
:alt: Odoo Community Association
123+
:target: https://odoo-community.org
124+
125+
OCA, or the Odoo Community Association, is a nonprofit organization whose
126+
mission is to support the collaborative development of Odoo features and
127+
promote its widespread use.
128+
129+
.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px
130+
:target: https://github.com/ivantodorovich
131+
:alt: ivantodorovich
132+
133+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
134+
135+
|maintainer-ivantodorovich|
136+
137+
This module is part of the `OCA/social <https://github.com/OCA/social/tree/16.0/mail_layout_force>`_ project on GitHub.
138+
139+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

mail_layout_force/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import wizards

mail_layout_force/__manifest__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com).
2+
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
{
6+
"name": "Mail Layout Force",
7+
"summary": "Force a mail layout on selected email templates",
8+
"version": "16.0.2.0.0",
9+
"author": "Camptocamp, Odoo Community Association (OCA)",
10+
"maintainers": ["ivantodorovich"],
11+
"website": "https://github.com/OCA/social",
12+
"license": "AGPL-3",
13+
"category": "Marketing",
14+
"depends": ["mail"],
15+
"demo": ["demo/mail_layout.xml"],
16+
"data": [
17+
"security/ir.model.access.csv",
18+
"data/mail_layout.xml",
19+
"views/ir_ui_views.xml",
20+
"views/mail_template.xml",
21+
],
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
Copyright 2022 Camptocamp SA (https://www.camptocamp.com).
4+
@author Iván Todorovich <ivan.todorovich@camptocamp.com>
5+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
6+
-->
7+
<odoo>
8+
9+
<template id="mail_layout_noop" name="Mail: No-Layout notification template">
10+
<t t-out="message.body" />
11+
</template>
12+
13+
</odoo>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
Copyright 2022 Camptocamp SA (https://www.camptocamp.com).
4+
@author Iván Todorovich <ivan.todorovich@camptocamp.com>
5+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
6+
-->
7+
<odoo>
8+
9+
<template id="mail_layout_custom">
10+
<table
11+
border="0"
12+
cellpadding="0"
13+
cellspacing="0"
14+
style="padding-top: 32px; background-color: red; width: 100%; border-collapse:separate;"
15+
>
16+
<tr>
17+
<td align="center">
18+
<table
19+
border="0"
20+
cellpadding="0"
21+
cellspacing="0"
22+
width="590"
23+
style="padding: 24px; background-color: white; border-collapse:separate;"
24+
>
25+
<tbody>
26+
<!-- HEADER -->
27+
<tr>
28+
<td align="center" style="min-width: 590px;">
29+
<table
30+
border="0"
31+
cellpadding="0"
32+
cellspacing="0"
33+
width="100%"
34+
style="background-color: white; padding: 0; border-collapse:separate;"
35+
>
36+
<tr>
37+
<td valign="middle">
38+
<t
39+
t-esc="model_description or 'document'"
40+
/>
41+
<t
42+
t-esc="message.record_name and message.record_name.replace('/','-') or ''"
43+
/>
44+
</td>
45+
<td valign="middle" align="right">
46+
<img
47+
t-att-src="'/logo.png?company=%s' % (company.id or 0)"
48+
style="padding: 0px; margin: 0px; height: 48px;"
49+
t-att-alt="'%s' % company.name"
50+
/>
51+
</td>
52+
</tr>
53+
<tr>
54+
<td colspan="2" style="text-align:center;">
55+
<hr
56+
width="100%"
57+
style="background-color: red; border: medium none; clear: both; display: block; margin:4px 0px 32px 0px;"
58+
/>
59+
</td>
60+
</tr>
61+
</table>
62+
</td>
63+
</tr>
64+
<!-- CONTENT -->
65+
<tr>
66+
<td style="min-width: 590px;">
67+
<t t-out="message.body" />
68+
</td>
69+
</tr>
70+
<!-- FOOTER -->
71+
<tr>
72+
<td
73+
align="center"
74+
style="min-width: 590px; padding: 0 8px 0 8px; font-size:11px;"
75+
>
76+
<hr
77+
width="100%"
78+
style="background-color: red; border: medium none; clear: both; display: block; margin:4px 0px 32px 0px;"
79+
/>
80+
<div style="color: #FF9999;">
81+
<b t-esc="company.name" /><br />
82+
<t t-esc="company.name" />
83+
<t t-if="company.phone">
84+
::
85+
<t t-esc="company.phone" />
86+
</t>
87+
<t t-if="company.email">
88+
::
89+
<a
90+
t-att-href="'mailto:%s' % company.email"
91+
style="text-decoration:none;color:red;"
92+
>
93+
<t t-esc="company.email" />
94+
</a>
95+
</t>
96+
<t t-if="company.website">
97+
::
98+
<a
99+
t-att-href="'%s' % company.website"
100+
style="text-decoration:none;color:red;"
101+
>
102+
<t t-esc="company.website" />
103+
</a>
104+
</t>
105+
</div>
106+
</td>
107+
</tr>
108+
</tbody>
109+
</table>
110+
</td>
111+
</tr>
112+
</table>
113+
</template>
114+
115+
</odoo>

0 commit comments

Comments
 (0)