| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 43 |
| Technical Name |
hc_integer_percentage |
| License | OPL-1 |
Integer Percentage Widget
Show any Integer field as 50% — without the multiplication magic of the built-in widget
Odoo 18 OWL Zero Python Any Model
Why not just use the built-in percentage widget?
Odoo's native widget="percentage" was designed for Float fields.
It treats the stored value as a fraction — so 0.5 is displayed as 50%.
When you apply it to an Integer field, the result is wrong:
| Widget | Field type | Stored value | Displayed as | Correct? |
|---|---|---|---|---|
percentage (built-in) |
Integer | 50 | 5,000% | ✗ |
integer_percentage (this module) |
Integer | 50 | 50% | ✓ |
Features
Correct display
Stored value 50 is shown as 50%. No hidden ×100 or ÷100 conversion.
Thousand-separator aware
Large values like 1000 are formatted per locale — e.g. 1,000%.
Smart input parsing
Users can type 50 or 50% — both save the integer 50 to the database.
Mobile-friendly
Uses inputmode="numeric" so mobile devices show the number keyboard automatically.
Works on any model
Not tied to hr.employee. Use widget="integer_percentage" on any Integer field in any view.
Pure OWL — zero Python
The widget is implemented entirely in JavaScript / OWL. No Python model changes are required.
How to use
Simply add widget="integer_percentage" to any <field> tag whose underlying field is an Integer:
<field name="discount_pct" widget="integer_percentage"/>
<field name="tax_rate" widget="integer_percentage" placeholder="0"/>
No configuration needed. The widget is registered globally as integer_percentage
and becomes available immediately after installing the module.
Compatibility
| Odoo version | Status |
|---|---|
| 18.0 | ✓ Supported |
| 17.0 and below | ✗ Not tested |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module