Introduction
Hello Odooers & Developers! Welcome to our Odoo technical article, where I'll be discussing how to use the progressbar widget in Odoo. Odoo provides various widgets to enhance the usability and display of fields in views, and one such useful widget is the progressbar.
In this article, you'll learn:
- What the progress bar widget is, and when to use it
- How to define a float or integer field for progress representation
- How to apply the progress bar widget in an XML view
- A practical example in a custom module
By the end of this article, you'll clearly understand how to use the progressbar to visually represent progress in your Odoo forms.
What is the progressbar Widget in Odoo?
The progress bar widget graphically displays a percentage-based value in Odoo views. This is particularly helpful for task completion percentages, stock quantities, or percentage-based progress monitoring.
For instance:
A field with a value of 50 (out of 100) will display a progress bar at 50% completion.
- A field with a value of 75 will display a filled progress bar to 75%.
This makes it easier for users to quickly understand the state of progress without reading numeric values.
Defining a Float Field for Progress in Python
Before using the progressbar widget, you need to define a field of type Float or Integer in your Odoo model. Below is an example where we define a progress field for a shop in a Mall Management (custom) module.
Python Model (.py)
.py
from odoo import models,fields
class Mall(models.Model):
_name = 'mall.shop'
_description='Shop'
progress = fields.Float(string='Progress', default=60.0
- Below is the explanation of the above code.
Explanation:
- We define a Float field named progress to store the progress percentage.
- The value should range from 0 to 100 to represent the percentage completion.
Using the progressbar Widget in XML View
Now, let's apply the progressbar widget in the form view to ensure that users see a visual representation of the progress percentage.
.py
<record id="view_shop_form" model="ir.ui.view">
<field name="name">view.shop.form</field>
<field name="model">mall.shop</field>
<field name="arch" type="xml">
<form string="Shop">
<sheet>
<group>
<field name="progress" widget="progressbar"/>
</group>
</sheet>
</form>
</field>
</record>
- Below is the explanation of the above code.
Explanation:
- The <field name="progress" widget="progressbar"/> applies to the progressbar widget.
- This ensures that Odoo will render a progress bar representing the field’s value as a percentage.
- Users can visually track progress instead of relying on numerical values.
Conclusion
In this blog, we discussed the progressbar widget, which facilitates the display of percentage-based values in a friendly visual form.
We covered:
✔ What is a progress bar, and why it's helpful
✔ How to represent a Float or Integer field for progress representation
✔ Application of the progress bar widget within an Odoo form view
✔ Hands-on application with a Custom Module example
Using the progress bar widget, you can improve the usability of progress-related fields in your Odoo modules.
If you want odoo technical training on any odoo version , please let us know by mail at [email protected]. Then next, our odoo expoert will conduct online or offline Odoo training with you
Devintellecs & team are odoo training providers in the USA and INDIA, so we will try our best to give the training either individal or any bulk employee company.
If you want to check your odoo technical or functional knowledge, then we have prepared the odoo EXam practice test for the odoo technical & functional people.