Skip to main content
iVentureTeam

l10n_in_hsn_autocomplete

Type three characters and Odoo asks India's GST portal for matching HSN codes. The request goes from the user's browser, not from your server, and that has consequences worth knowing before you deploy it.

Siddharth JambukiyaSiddharth JambukiyaOdoo Techno-Functional Consultant
August 27, 2026Updated September 8, 20266 min read
Technical namel10n_in_hsn_autocomplete
Field typeschar, text
Viewsform, list
Modulel10n_in, the Indian localization
Used in core1 occurrence, the HSN code on the product template form in l10n_in
VersionsOdoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0
No-code setupNo. It ships with the Indian localization and is set in view XML
Alternativeschar, many2one, text

What the HSN autocomplete does

Every product sold in India needs an HSN code, and every service a SAC code. They are classification numbers from a government schedule, they determine the GST rate, and nobody remembers them. Looking one up normally means leaving Odoo for the GST portal, searching there, and copying a number back.

This widget removes that round trip. As you type in the HSN field it queries the GST portal's own search service and shows the matching codes as suggestions, with their official descriptions. Choosing one writes the code, and can also write the description into a second field.

The search adapts to what you type. If the input is digits only, it searches by code. If it contains anything else, it runs two description searches in parallel, one for products and one for services, so the same box works for both classifications.

What this means for your team

Wrong HSN codes are a compliance problem with a direct cost: the code drives the GST rate on the invoice, and a mismatch turns into a return correction or a notice. Getting the classification right at product setup, from the official source, is cheaper than reconciling it afterwards.

The point that belongs in a deployment decision is where the request comes from. The call is made by the browser of whoever is editing the product, straight to the government service. Your Odoo server is not involved. That means it works without any server-side network configuration, and equally that it will not work for a user behind a network that blocks the destination, and that the request carries whatever the user's browser carries.

It also means the feature degrades rather than breaks. If the service is unreachable or slow, the dropdown shows a single entry saying it could not contact the API, and the field remains an ordinary text input the user can type into. Nothing blocks saving the product.

Supported options in Odoo 19

One option is declared. It is worth reading the note below carefully, because the widget replaces the text widget's extractor entirely, which silently removes everything the base widget would normally accept. Read from hsn_autocomplete.js and the char field, Odoo 19.0.

OptionTypeWhat it does
hsn_description_fieldstring (field name)Technical name of a field that receives the official description when a suggestion is chosen. Declared as a string, though the value is a field name. Without it only the code is written.

Inherited options and attributes are dead here. The descriptor spreads the text widget but then defines its own extractProps that returns only the description field name. Nothing else is extracted, so the placeholder attribute, the dynamic placeholder option and the password and autocomplete attributes all stop working on this field, with no warning. The option's declared type is also loose: it is announced as a string, and the value it takes is a technical field name.

Working examples

The core usage

<field name="l10n_in_hsn_code"
       widget="l10n_in_hsn_autocomplete"
       invisible="'IN' not in fiscal_country_codes"/>

The field is hidden entirely outside Indian fiscal setups, which is why most Odoo databases never see this widget.

Filling a description too

<field name="l10n_in_hsn_code"
       widget="l10n_in_hsn_autocomplete"
       options="{'hsn_description_field': 'l10n_in_hsn_description'}"/>

With the option set, choosing a suggestion writes both the code and its official description in one update.

What no longer works on this field

<!-- the placeholder is silently ignored -->
<field name="l10n_in_hsn_code"
       widget="l10n_in_hsn_autocomplete"
       placeholder="e.g. 8471"/>

The widget's extractor does not read it, so it never reaches the input.

A browser calling a government API

The request logic is worth spelling out because it is unusual for an Odoo widget. Three query shapes are defined: search by code, search product descriptions, and search service descriptions. If the typed value is numeric and contains no space, only the code search runs. Otherwise the two description searches run in parallel.

Each request carries its own abort controller with a five second timer, so a slow service does not leave the dropdown hanging. All the requests are awaited together, and any failure anywhere collapses into a single suggestion reading that the API could not be contacted, plus a console warning. There is no retry.

Results are filtered before they are shown: an entry whose code is three characters or shorter is discarded. HSN codes are used at four, six or eight digits depending on turnover, so the shortest schedule entries are noise for a product form.

Selecting a suggestion is wrapped in a deferred call rather than being applied immediately. That is a common pattern when a selection has to land after the autocomplete has finished closing, and it means the write happens on the next tick rather than inside the click handler.

Between Odoo 18 and Odoo 19 the suggestion objects were restructured: each one now carries the description as data and its own selection handler, rather than being mapped into a flat list. The behavior a user sees is the same, but a custom module patching the suggestion shape will notice.

Version compatibility

VersionStatusNotes
Odoo 20.0In developmentNot released. Behavior identical on the development branch; only props and reference helpers change.
Odoo 19.0VerifiedVerified against the shipped source. Suggestion objects restructured, behavior unchanged.
Odoo 18.0VerifiedSame option and same lookup, with a flatter suggestion shape.
Odoo 17.0VerifiedFirst version.
Odoo 16.0Not availableWidget does not exist.

Upgrade note. The widget and its option have been the same since Odoo 17, so views carry over. Odoo 19 changed the internal shape of the suggestion objects and dropped an unused flag from the source definition, which matters only to custom JavaScript. Note also that the field is gated on Indian fiscal settings in the core view, so an upgrade only surfaces it where the localization is active.

What is changing in Odoo 20

Odoo 20 is expected at Odoo Experience in Brussels, 24 to 26 September 2026. The development branch is unstable and this may still change; we re-verify the page after release.

No behavior change. The service address, the three query shapes, the five second timeout, the three character minimum and the code length filter are all identical. The differences are the migration to the new Owl props and reference helpers, which affect patches rather than views.

Common problems and fixes

SymptomCause and fix
The dropdown says it could not contact the APIThe request from the user's browser to the government service failed or timed out after five seconds. Check the user's network and any corporate filtering. The field still accepts typed input.
No suggestions appear at allFewer than three characters have been typed. Type at least three characters; the source only queries beyond that length.
A code I know exists is missingEntries with a code of three characters or fewer are filtered out. Type more of the code, or enter the value manually.
The description field is not filledThe hsn_description_field option is not set. Add options="{'hsn_description_field': 'your_field'}" naming the description field.
The placeholder is ignoredThe widget replaces the text widget's extractor, so the placeholder never reaches the input. Use a label or help text instead.
The field is not visibleThe core view hides it unless the company's fiscal country is India and GST registration is enabled. Check the fiscal localization settings.
Suggestions are slowThe lookup is a live call to an external service, with a five second ceiling. Nothing to tune in Odoo; the timeout is fixed in the source.

HSN autocomplete vs the alternatives

WidgetBest forKey difference
l10n_in_hsn_autocompleteFinding an official HSN or SAC code without leaving the product formQueries India's GST portal live from the browser and can fill a description field alongside the code
charTyping a code you already knowNo lookup, but every inherited option and attribute still works
many2oneChoosing from a schedule imported into your own modelA real relation with server-side search, no external dependency
textLonger free textTextarea rendering, no suggestions

There is no alternative that does the same job, because the lookup is specific to the Indian schedule. If the government service is unreachable in your environment, the honest fallback is the plain text widget plus an internal reference list, or a server-side import of the schedule into a model you control, which also gives you a searchable relation instead of a free text field.

Frequently asked questions

Where do the HSN suggestions come from?+
A live call to India's GST portal search service, made by the user's browser rather than by your Odoo server. Nothing is cached on the server side.
What happens if the service is unreachable?+
Each request is aborted after five seconds and the dropdown shows a single entry saying the API could not be contacted. The field stays usable as a plain input.
Why do some codes never appear?+
Results whose code is three characters or shorter are filtered out, because HSN codes are used at four digits and above on product records.
Can it fill the description as well?+
Yes. Set the hsn_description_field option to the technical name of the field that should receive the official description; picking a suggestion then writes both in one update.
Why does my placeholder not show?+
The widget replaces the text widget's extractor with its own, which returns only the description field name. Everything the base widget would have extracted, including the placeholder, is silently dropped.

GST compliance that does not depend on one person's memory

HSN classification, e-invoicing and GST returns in Odoo depend on product data being right long before the return is filed. We implement and verify the Indian localization on Odoo 16 through 19, from chart of accounts to e-invoice submission.

Book a free consultation

How this page was produced

The query shapes, the five second abort, the three character minimum, the code length filter, the failure suggestion and the replaced extractor were read from hsn_autocomplete.js on the Odoo 19.0 branch, with the inherited option set read from the char field in web. The usage and its visibility condition come from l10n_in/views/product_template_view.xml. Version differences come from the same file on the 17.0 and 18.0 branches, and the Odoo 20 notes from the public development branch. Spotted an error? Tell us and we will correct the page.