OdooWiki OCA HUB

Text from HTML field

html_text folder_open OCA/server-tools open_in_new
Tools License: AGPL-3

This module provides some technical features that allow to extract text from any chunk of HTML, without HTML tags or attributes. You can chose either:

  • To truncate the result by amount of words or characters.
  • To append an ellipsis (or any character(s)) at the end of the result.

It can be used to easily generate excerpts.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

This module adds a helper that turns any HTML content into plain text, so excerpts can be generated without tags or attributes. It can limit the result by words or characters and add an ellipsis when the text is cut.

This is a technical tool for developers and report designers. It extends the existing field converter (ir.fields.converter) with a new method called text_from_html that takes HTML content and returns clean text.

  • You can set a maximum number of words (max_words) or a maximum number of characters (max_chars).
  • When the text is truncated, a suffix such as an ellipsis (…) is appended; you can choose any characters or none.
  • If the HTML cannot be parsed, the method returns an empty string by default, or raises an error if fail is set to true.

There are no new menus, screens, buttons, or reports. The feature is only available programmatically, for example when building excerpts for emails, portal pages, or custom reports. It does not change any user interface or business workflow by itself; it only provides a reusable way to extract readable text from HTML fields.

Depends on

base
Models and fields (1)
  • ir.fields.converter · extends an existing model

Text generated by AI (DeepSeek) from reading the Odoo 18.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 7 confirmed, 2 with no information of 9 versions.

Sources · Odoo 17.0

Confirmed on 2026-11-03 in branch 17.0 of OCA/server-tools.

terminal Installation and usage

OCA documentation · Odoo 18.0

This module just adds a technical utility, but nothing for the end user.

If you are a developer and need this utility for your module, see these examples and read the docs inside the code.

Python example:

def some_method(self): # Get truncated text from an HTML field. It will 40 words and 100 # characters at most, and will have "..." appended at the end if it # gets truncated. truncated_text = self.env["ir.fields.converter"].text_from_html( self.html_field, 40, 100, "...")

QWeb example:

[](https://runbot.odoo-community.org/runbot/149/11.0)

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.