OdooWiki OCA HUB

Simple many2one widget

web_widget_many2one_simple folder_open OCA/web open_in_new
Uncategorised License: AGPL-3

This module adds a new widget to many2one fields that allows to link records without any extra features (no autocomplete and no partial search).

  • Preview

auto_awesome What this module does

AI-generated from the code · Odoo 15.0

Adds a new 'many2one_simple' widget for many2one fields that links records by exact search instead of autocomplete. Users type a value, press Enter or Tab, and Odoo searches for one matching record.

This module adds a new field widget called 'many2one_simple' that can be applied to any many2one field in Odoo forms. Unlike the standard many2one field, it does not show autocomplete suggestions or partial search results; the user types a value and Odoo looks for exactly one matching record.

When the user leaves the field or presses Enter/Tab, the widget searches the related model using the configured search field and operator. If exactly one record is found, it is linked. If no record is found and creation is allowed, a popup opens to create a new record, optionally pre-filling the search field with the typed value. If creation is not allowed, an error message is shown.

  • The widget can be configured with options such as 'search' (field and operator), 'regex' for input validation, 'can_create', 'can_write', and 'no_open'.
  • In read-only mode, the linked record is displayed as a clickable link that opens its form view, unless 'no_open' is set.
  • An external link button is available in edit mode to open the linked record in a dialog.

The module includes a demo view that applies the widget to the 'industry_id' field on the partner form, searching by exact name. It does not add new models or menus; it only extends the web client's field registry and provides a new widget template.

Depends on

web

Text generated by AI (DeepSeek) from reading the Odoo 15.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: 3 confirmed, 6 with no information of 9 versions.

terminal Installation and usage

OCA documentation · Odoo 15.0

Attributes:

* regex [String]: Defines the regex to test the search criteria
* can_create [Boolean]: Allow create new records
* can_write [Boolean]: Allow edit the linked record

Options:
  • search [Dictionary]
  • field: The field to use in the search process [Default is 'id']
  • oper: The operator (like, ilike, etc...) [Default is '=']
  • no_create: Invalidates the 'can_create' flag
  • no_write: Invalidates the 'can_write' flag
  • no_open: Disables open the linked record

You need to declare the usage of the new widget as follows: <field name="xxx" widget="many2one_simple" options="...">

If you have a database with demo data, you can test this widget following these instructions:

  • Go to Contacts.
  • Create or edit a record.
  • Set "Industry" field (in Sales & Purchase tab).
  • Only if you set the correct industry name ("Administrative" for example), it will be defined. Otherwise, it will try to create one with that name.

Example:

.. code:: xml

  <field name="partner_id" widget="many2one_simple" regex="^1\d*" options="{&quot;search&quot;: { &quot;field&quot;: &quot;name&quot;, &quot;oper&quot;: &quot;ilike&quot; }}"/

** Only allows search by id's that starts with '1' ...

No verified information in OCA: Installation.

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.