Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to remove the zero value of float field in tree view [Closed]

By
Vivekrajan
on 5/24/13, 5:39 AM 3,124 views

The Question has been closed

by
Francesco OpenCode
on 05/27/2013 08:42:16

Hi dear friends,

Just assume that a float type field is added in a tree view(many2many list or any list view). The float value defaults to zero always and the value zero is shown in the list or tree view as well.

Is there a way to remove the value zero or hide the zero value that is shown in the tree view?

But the value if it is entered will always be float value.. No change in that.

This is my client's requirement. May be silly. But please help me to find a workaround.

Thanks.

3
Vivekrajan
On 5/27/13, 7:16 AM

Hi Everyone,

I have found the solution to hide the zero values from the tree view.

Example implementation in the view xml file. The below code hides the zero values in the tree view. The field dummy_hieght is in the tree view But it does not show up the zero values.

<field name="dummy_height" string="Height" attrs="{'invisible':[('dummy_height','=',0.0)]}"/>

That is it. Enjoy the day!

use this can't edit it

codefans
on 9/13/13, 5:35 AM

Hi vivekrajan, The code is working in tree view. I also want to hide Zero values in form view also with editable field. Is any way?

Prakash
on 2/3/14, 2:26 AM

Sorry Prakash. If you try to use the specified attribute in form view, it will completely hide the field as the initial value will be always Zero. It will not be a good idea to hide Zero value in the form view. I have done it for tree view since it was my client's wish. If you still want to hide the Zero value, I shall try to find a work around and let you know

Vivekrajan
on 2/4/14, 8:13 AM

Thank you

Prakash
on 2/4/14, 8:24 AM
1
zuher83
On 12/17/14, 5:35 AM

The best solution is:

Extend with new module base.xml:

   <t t-extend="ListView.row">
        <t t-jquery="td" t-operation="replace"/>

        <t t-jquery="th" t-operation="after">

        <t t-foreach="columns" t-as="column">
            <t t-set="number" t-value="column.type === 'integer' or column.type == 'float'"/>
            <t t-set="modifiers" t-value="column.modifiers_for(asData)"/>

            <td t-if="!column.meta and column.invisible !== '1'" t-att-title="column.help"
                t-attf-class="oe_list_field_cell oe_list_field_#{column.widget or column.type} #{number ? 'oe_number' : ''} #{column.tag === 'button' ? 'oe-button' : ''} #{modifiers.readonly ? 'oe_readonly' : ''} #{modifiers.required ? 'oe_required' : ''}"
                t-att-data-field="column.id"
                t-attf-data-field-value="#{number ? record.get(column.id) : ''}"
                ><t t-raw="render_cell(record, column)"/></td>
            </t>
            <td t-if="options.deletable" class='oe_list_record_delete' width="13px">
                <button type="button" name="delete" class="oe_i">d</button>
            </td>
        </t>
    </t>

And add new css class with:

    [data-field-value='0'] {
        color: transparent;
    }

It works perfectly. You can edit without problem. If the value changes, it automatically updates and becomes visible

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/24/13, 5:39 AM
Seen: 3124 times
Last updated: 5/11/15, 2:34 PM