Skip to content

Commit 2bc5033

Browse files
[ADD] web_export_html_as_text
1 parent 4f90e2c commit 2bc5033

File tree

17 files changed

+699
-0
lines changed

17 files changed

+699
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../web_export_html_as_text
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

web_export_html_as_text/README.rst

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
=======================
2+
Web Export Html As Text
3+
=======================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:2146e2848f91f88561de66315cd667a5da2271a1803285722619230788424ecd
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%2Fweb-lightgray.png?logo=github
20+
:target: https://github.com/OCA/web/tree/16.0/web_export_html_as_text
21+
:alt: OCA/web
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_export_html_as_text
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/web&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows exporting HTML fields as plain text.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Configuration
39+
=============
40+
41+
To export HTML fields as plain text:
42+
43+
- Open any list view.
44+
- Select the records, then click Export under the Action menu.
45+
- Enable "Export HTML as text" in the export dialog.
46+
47+
Note: This setting will apply to all HTML fields exported in the current export dialog.
48+
49+
Known issues / Roadmap
50+
======================
51+
52+
Rich formatting (bold, italic, underline, colors, fonts, alignment) cannot be preserved in exports.
53+
Such characters and styles are simplified to plain text markers.
54+
55+
Bug Tracker
56+
===========
57+
58+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
59+
In case of trouble, please check there if your issue has already been reported.
60+
If you spotted it first, help us to smash it by providing a detailed and welcomed
61+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_export_html_as_text%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
62+
63+
Do not contact contributors directly about support or help with technical issues.
64+
65+
Credits
66+
=======
67+
68+
Authors
69+
~~~~~~~
70+
71+
* Quartile
72+
73+
Contributors
74+
~~~~~~~~~~~~
75+
76+
* `Quartile <https://www.quartile.co>`_
77+
78+
* Aung Ko Ko Lin
79+
80+
Maintainers
81+
~~~~~~~~~~~
82+
83+
This module is maintained by the OCA.
84+
85+
.. image:: https://odoo-community.org/logo.png
86+
:alt: Odoo Community Association
87+
:target: https://odoo-community.org
88+
89+
OCA, or the Odoo Community Association, is a nonprofit organization whose
90+
mission is to support the collaborative development of Odoo features and
91+
promote its widespread use.
92+
93+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_export_html_as_text>`_ project on GitHub.
94+
95+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Web Export Html As Text",
5+
"version": "16.0.1.0.0",
6+
"website": "https://github.com/OCA/web",
7+
"author": "Quartile, Odoo Community Association (OCA)",
8+
"category": "Tools",
9+
"license": "AGPL-3",
10+
"depends": ["base"],
11+
"assets": {
12+
"web.assets_backend": [
13+
"web_export_html_as_text/static/src/js/*.esm.js",
14+
"web_export_html_as_text/static/src/xml/*.xml",
15+
],
16+
},
17+
"installable": True,
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, models
5+
from odoo.tools import html2plaintext
6+
7+
8+
class BaseExportHtmlAsText(models.AbstractModel):
9+
_inherit = "base"
10+
11+
@api.model
12+
def export_data(self, fields_to_export):
13+
res = super().export_data(fields_to_export)
14+
if not self.env.context.get("export_html_as_text"):
15+
return res
16+
datas = res.get("datas", [])
17+
if not datas:
18+
return res
19+
field_types = self.fields_get(fields_to_export, attributes=["type"])
20+
html_indexes = [
21+
i
22+
for i, p in enumerate(fields_to_export)
23+
if field_types.get(p, {}).get("type") == "html"
24+
]
25+
if not html_indexes:
26+
return res
27+
for row in datas:
28+
for idx in html_indexes:
29+
if isinstance(row[idx], str) and row[idx]:
30+
row[idx] = html2plaintext(row[idx])
31+
return {"datas": datas}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
To export HTML fields as plain text:
2+
3+
- Open any list view.
4+
- Select the records, then click Export under the Action menu.
5+
- Enable "Export HTML as text" in the export dialog.
6+
7+
Note: This setting will apply to all HTML fields exported in the current export dialog.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `Quartile <https://www.quartile.co>`_
2+
3+
* Aung Ko Ko Lin
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows exporting HTML fields as plain text.

0 commit comments

Comments
 (0)