This question has been flagged

As you may know, if you want to order a model by some of its fields, you have to modify the attribute _order of the model. It works fine.

Now, suppose you want to order a specific view by some fields without altering the normal order of the model (this means: order a specific view by some fields and the rest of the views of the same model by other fields).

In this case, you have to use XML code, specifying the attribute default_order in the kanban or tree tag, depending on which view you are modifying.

I've used this in the past succesfully. So I wanted to apply this again to a kanban view (this time I want to order by a boolean field, a char and another char).

Now my surprise: ordering by a boolean field reverses the order of the next fields if it values False.

e.g. We have 6 records, which we want to order by a boolean, the name, and surname; in a kanban view with default_order, so we write <kanban default_order="my_boolean_field,name,surname">. Doing this, with the following records:

  • True, John, Doe

  • True, Jane, Doe

  • True, John, Xoe

  • False, John, Die

  • False, Jane, Die

  • False, Jane, Xie

In the kanban view, we'll see them ordered this way:

  1. True, Jane, Doe

  2. True, John, Doe

  3. True, John, Xoe

  4. False, John, Die

  5. False, Jane, Xie

  6. False, Jane, Die

As you can see, if the boolean values True, the records are ordered by boolean, name and surname, which is what I want. But if it values False, the records are ordered by boolean, name DESC, surname DESC.

What's going on? Did you experience the same? How can I order by a boolean, then a char, and then another char??

Avatar
Discard