Skip to content
Open
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
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# generated from manifests external_dependencies
cryptography
emoji_data_python
endesive ; python_version >= '3.12'
endesive<=2.18.5 ; python_version < '3.12'
mock
openpyxl
py3o.formats
py3o.template
twemoji_api
1 change: 1 addition & 0 deletions setup/web_emojis/odoo/addons/web_emojis
6 changes: 6 additions & 0 deletions setup/web_emojis/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
79 changes: 79 additions & 0 deletions web_emojis/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
==========
Web Emojis
==========

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

.. |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%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/16.0/web_emojis
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-web_emojis
: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/reporting-engine&target_branch=16.0
:alt: Try me on Runboat

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

Replaces emojis with Twemoji images in PDF reports.

Emojis cannot be rendered by wkhtmltopdf. This module automatically converts
them to img tags pointing to Twemoji images before PDF generation.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/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/reporting-engine/issues/new?body=module:%20web_emojis%0Aversion:%2016.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
~~~~~~~

* Lambdao

Contributors
~~~~~~~~~~~~

* len <len@lambdao.dev>

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/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/web_emojis>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions web_emojis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2026 Lambdao
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
32 changes: 32 additions & 0 deletions web_emojis/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2026 Lambdao
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

# workaround module for:
# https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2913
# wkhtmltopdf supports some emojis in black & white only, and color
# emojis aren't supported at all.
# For example, ⚠️ would be rendered as simple line drawing in pdf,
# and not as a colorful yellow warning sign.
# Meanwhile, 🇫🇷 would render as missing glyphs instead of the French flag.
# So it's not perfect as true emoji support would mean that copy-paste
# would work while this is not the case with this workaround.


{
"name": "Web Emojis",
"summary": """
Replaces emojis with Twemoji images in PDF reports.

Emojis cannot be rendered by wkhtmltopdf. This module automatically converts
them to img tags pointing to Twemoji images before PDF generation.
""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Lambdao, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"category": "Technical",
"depends": ["base"],
"external_dependencies": {"python": ["emoji_data_python", "twemoji_api"]},
"demo": ["report/demo_report.xml"],
"installable": True,
}
4 changes: 4 additions & 0 deletions web_emojis/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2026 Lambdao
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import ir_actions_report
62 changes: 62 additions & 0 deletions web_emojis/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2026 Lambdao
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import logging

from emoji_data_python import get_emoji_regex
from twemoji_api import get_emoji_url

from odoo import models

_logger = logging.getLogger(__name__)


def _emoji_to_img(match):
"""Replace an emoji match with an img tag."""
emoji = match.group(0)
try:
url = get_emoji_url(emoji)
except ValueError:
return emoji
# flake8: noqa
return (
f'<img src="{url}" alt="{emoji}" '
f'style="height: 1em; width: 1em; vertical-align: -0.1em;">'
)


def replace_emojis(html):
"""Replace emojis in HTML with Twemoji img tags."""
if not html:
return html
return get_emoji_regex().sub(_emoji_to_img, html)


class IrActionsReport(models.Model):
_inherit = "ir.actions.report"

def _run_wkhtmltopdf(
self,
bodies,
report_ref=False,
header=None,
footer=None,
landscape=False,
specific_paperformat_args=None,
set_viewport_size=False,
):
bodies = [replace_emojis(body) for body in bodies]
# headers and footers are already problematic enough
# if header:
# header = replace_emojis(header)
# if footer:
# footer = replace_emojis(footer)
return super()._run_wkhtmltopdf(
bodies,
report_ref=report_ref,
header=header,
footer=footer,
landscape=landscape,
specific_paperformat_args=specific_paperformat_args,
set_viewport_size=set_viewport_size,
)
1 change: 1 addition & 0 deletions web_emojis/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* len <len@lambdao.dev>
4 changes: 4 additions & 0 deletions web_emojis/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Replaces emojis with Twemoji images in PDF reports.

Emojis cannot be rendered by wkhtmltopdf. This module automatically converts
them to img tags pointing to Twemoji images before PDF generation.
53 changes: 53 additions & 0 deletions web_emojis/report/demo_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2026 Lambdao
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<template id="report_emoji_demo_document">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<h1>Emoji Demo Report</h1>
<p>This report demonstrates emoji rendering in PDF reports.</p>

<h2>Flags</h2>
<table class="table table-sm">
<tr><td>France</td><td>🇫🇷</td></tr>
<tr><td>United States</td><td>🇺🇸</td></tr>
<tr><td>Germany</td><td>🇩🇪</td></tr>
<tr><td>Japan</td><td>🇯🇵</td></tr>
<tr><td>United Kingdom</td><td>🇬🇧</td></tr>
<tr><td>Canada</td><td>🇨🇦</td></tr>
<tr><td>Brazil</td><td>🇧🇷</td></tr>
<tr><td>Australia</td><td>🇦🇺</td></tr>
</table>

<h2>Common Emojis</h2>
<table class="table table-sm">
<tr><td>Smileys</td><td>😀 😃 😄 😁 😆 😅 🤣 😂</td></tr>
<tr><td>Hearts</td><td>❤️ 🧡 💛 💚 💙 💜 🖤 🤍</td></tr>
<tr><td>Hands</td><td>👍 👎 👏 🙌 🤝 🙏 ✌️ 🤞</td></tr>
<tr><td>Animals</td><td>🐶 🐱 🐭 🐹 🐰 🦊 🐻 🐼</td></tr>
<tr><td>Food</td><td>🍎 🍐 🍊 🍋 🍌 🍉 🍇 🍓</td></tr>
<tr><td>Weather</td><td>☀️ 🌤️ ⛅ 🌦️ 🌧️ ⛈️ 🌩️ 🌨️</td></tr>
<tr><td>Objects</td><td>📱 💻 🖥️ 🖨️ ⌨️ 🖱️ 💾 💿</td></tr>
<tr><td>Symbols</td><td>✅ ❌ ⭐ 🔴 🟢 🔵 ⚠️ ℹ️</td></tr>
</table>

<h2>Inline Text</h2>
<p>Emojis can be used inline: The weather is ☀️ sunny today!</p>
<p>Status: ✅ Completed | Priority: ⭐⭐⭐ | Location: 🇫🇷 France</p>
</div>
</t>
</t>
</template>

<record id="action_report_emoji_demo" model="ir.actions.report">
<field name="name">Emoji Demo</field>
<field name="model">res.company</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">web_emojis.report_emoji_demo_document</field>
<field name="report_file">web_emojis.report_emoji_demo_document</field>
<field name="binding_model_id" ref="base.model_res_company" />
<field name="binding_type">report</field>
</record>
</odoo>
Loading