콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
27572 화면

Hello there,

Here is my code to customize « external identifiers » view. I added a ID column.

But when I add a new column like this in a view, I CAN NOT sort lines according to this new column. If I click the header of the table, nothing arrives. How could it work?

Also, how could I get the little triangle icon in the header when the column is sorted? (see the triangle at the right of Model Name)

 

 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record id="base.view_model_data_list" model="ir.ui.view">
            <field name="model">ir.model.data</field>
            <field name="arch" type="xml">
                <tree string="External Identifiers">
                    <field name="id"/>
                    <field name="complete_name"/>
                    <field name="display_name"/>
                    <field name="model" groups="base.group_no_one"/>
                    <field name="module" invisible="1"/>
                    <field name="res_id"/>
                </tree>
            </field>
        </record>


    </data>
</openerp>

 

Thanks

아바타
취소

I would like to know how to make an added column sortable, too!

@Jeff, in general all stored columns are sortable. I've just learned that in v8 the ID column is not. So, as long as your column is stored in the database you can just add the field into the tree view and it will be sortable.

I added the "Internal Reference" (default_code) field to the Product list view. Unfortunately, it remains unsortable. I can click on the header cell all I want, but it doesn't work. There must be some way that you have to designate the column as sortable.

Ah! I looked in the database, and I see that "default_code" is actually stored in product.product, not product.template, which is the base table for the Products list view. Is that why it's not sortable? It's not a member of the base table?

I guess so. However I'm amazed if you can display default_code in a view based on product.template. New things to learn everyday. Thanks for sharing.

베스트 답변

@Pascal, I tried adding the id field as you have done (using OpenERP v7) and I can sort based on the ID field.  Note that you can only sort by 1 column at any time.  Note that you cannot sort by Complete ID and Display Name as they are function fields.  You did not redefined the ID field, did you?

아바타
취소
작성자

I didn't redefined the ID field. Should I? How?

작성자

I'm in Odoo v8

No, you shouldn't need to redefine the field. Haven't tried it in v8.

@Pascal I've tried on v8. It seems that all ID columns are deemed unsortable in v8. If you add other fields like create_uid, you can still sort by that column. Sorry, can't help you further on this.

작성자

Thanks Ivan

베스트 답변

Hi,

another way to test, perhaps try to redefine _order attribute of your class:

class Myclass(models.Model):

    _inherit = 'my.class'

    _order = 'id desc, name desc'

else you can tried to use attribute  default_order in tree or kanban view

Regards

아바타
취소
관련 게시물 답글 화면 활동
0
7월 24
1455
0
7월 17
5380
1
3월 15
7397
1
12월 24
4544
1
2월 24
2452