This question has been flagged
3 Replies
12156 Views

Hello everybody!!!

I want to order my view tree.

SO that, i tried the key 'default_order'.

Here is what i tried:

My Python class:

class test_momo(models.Model):

    _name = "test.momo"

    _order = 'temps_attente asc,id'

and in my view tree:

<record id="test_momo_tree" model="ir.ui.view">

        <field name="name">test.momo.tree</field>

        <field name="model">test.momo</field>

        <field name="arch" type="xml">

            <tree string="Request" default_order='temps_attente desc' colors="red:state=='refuse'; orange:state=='validate1'; green:state=='validate'">

  <field name="employee_id"/>

  <field name="request_date"/> 

         <field name="state"/>  

     </tree>

        </field>

    </record>

But i haven' got anything.



Avatar
Discard

Hi just add like this in python file only,

_order = "field_name desc"

or

_order = "field_name asc"

I'm not sure if you can give asc or desc in xml, but default_order in tree view should work.

Best Answer

Check if there isn't an inherited view already sorting your list. Also checkout if there's  any sorting in your code or another inherited code already sorting things. 

Avatar
Discard