Skip to content
Advertisement

How to make odoo progress bar use decimal?

So I am learning odoo right now, and I want to make the progress bar that use decimal to determine it’s percentage. so for example if I input a 0.5, the progress bar will show 50%, so I don’t have to input 50 to get 50%. I tried using options like below

PY

progress = fields.Float(string='Progress')
maximum_rate = fields.Float(string='Maximum Rate', default=1)

XML

<field name="maximum_rate" invisible="1"/>
<field name="progress" widget="progressbar" options="{'max_value': 'maximum_rate', 'editable': True}"/>

but the output is either 0/1 or 1/1, it’s always on integer value, and it’s also not a percentage. so how do I make my progress bar show percentage using decimal value like 0.5 to show 50%?

Advertisement

Answer

If the max_value is different from 100, Odoo will compute the value using the following:

if (max_value !== 100) {
    this.$('.o_progressbar_value').text(utils.human_number(value) + " / " + utils.human_number(max_value));
}

Unfortunately, you can’t change this behavior using widget options

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement