Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
16717 Lượt xem

Hello everyone

I have the following tree view:

<record id="mymodule_customers_tree_view" model="ir.ui.view">
    <field name="name">Customers List</field>
    <field name="model">mymodule.customers</field>
    <field name="arch" type="xml">
      <tree>
              <field name="name"/>
              <field name="address"/>
              <field name="city"/>
       </tree>
    </field>
  </record> 

Everytime I add a new record, on the tree view this new record is shown at the end of the list.

How can change this behavior and add the new records to the top of the list?

Thank you in advance

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

For this what you can do is that give default_order for the tree view, see the sample,

<tree string="Messages" default_order="id desc">


In your case,


<record id="mymodule_customers_tree_view" model="ir.ui.view">
<field name="name">Customers List</field>
<field name="model">mymodule.customers</field>
<field name="arch" type="xml">
<tree default_order="id desc">
<field name="name"/>
<field name="address"/>
<field name="city"/>
</tree>
</field>
</record>

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you Cybrosys.

I think this "id desc" refers to "desc= descendant" is that correct?

Thank you once again. It's working as expected

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 4 25
4809
5
thg 11 23
43175
3
thg 10 23
8949
3
thg 9 23
9567
1
thg 9 23
3393