OdooWiki OCA HUB

Input patterns

web_widget_pattern folder_open OCA/web open_in_new
Technical License: AGPL-3

This module allows to use patterns in text fields in the backend.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

Lets developers add a validation pattern to text fields so Odoo checks what users type and shows an error when the value does not match.

This is a technical module that adds a new option to text fields in Odoo. When a field is given a pattern, Odoo checks the value typed by the user against that pattern and refuses to accept it if it does not match.

  • The pattern can be set on the field definition in the code, or directly in a view by adding a pattern attribute to a field.
  • The check happens when the field is saved or parsed, and the user sees an error message saying the value does not match the required pattern.
  • The module also makes the pattern available to the web client so the browser input can carry the same rule.

The module touches the base model layer, so the pattern option becomes available for text fields across Odoo. It also patches the standard character field widget in the backend, which is the input box used for short text values.

A demo view is included that applies a numeric-only pattern to the second address line of the contact form, showing how the feature is used. No new menus, reports, or scheduled actions are added; the change is limited to field validation in backend forms.

Depends on

web
Models and fields (1)
  • base · 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: 2 confirmed, 7 with no information of 9 versions.

terminal Installation and usage

OCA documentation · Odoo 18.0

You can either define a pattern in your Python source code on a field as in

my_field = fields.Char(pattern='[0-9]')

or on view level as in

<field name="my_field" pattern="[0-9]" />

Demo data adds a pattern on the street2 field on partner forms to only allow numbers.

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.