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

Hello,

I want to change the tree list item colors with my own field functions.

purchase_view.xml:

    <record model="ir.ui.view" id="view_purchase_color_open_orders">
    <field name="name">purchase_order_tree_color_open_orders</field>
    <field name="model">purchase.order</field>
    <field name="inherit_id" ref="purchase.purchase_order_tree"/>
    <field name="arch" type="xml">            
        <xpath expr="//tree[@string='Purchase Order']" position="inside">
            <field name="is_green" invisible="1"/>
            <field name="is_orange" invisible="1"/>
            <field name="is_red" invisible="1"/>
        </xpath>
        <xpath expr="//tree[@string='Purchase Order']" position="attributes">
            <attribute name="colors">                    
                green:is_green=='True';
                orange:is_orange=='True';
                red:is_red=='True'
            </attribute>
        </xpath>
    </field>
</record>

is_green, is_orange and is_red are my functions and this is the definition:

    _columns = {
             'is_green': fields.function(_is_green, type = 'boolean'),
             'is_orange': fields.function(_is_orange, type = 'boolean'),
             'is_red': fields.function(_is_red, type = 'boolean'),
               }

The functions works without any problem, but the view color all items green (always the first color).

I also tryed:

            <attribute name="colors">                    
                green:('is_green', '=', 'True');
                orange:('is_orange', '=', 'True');
                red:('is_red', '=', 'True')
            </attribute>

with the same result.

Is this the right way, or is there another opportunity to solve the problem?

Regards,

Sebastian

아바타
취소
작성자 베스트 답변

I find the solution:

        <xpath expr="//tree[@string='Purchase Order']" position="attributes">
            <attribute name="colors">
                green:is_green==True;
                orange:is_orange==True;
                red:is_red==True
            </attribute>
        </xpath>

U have to compare boolean values without ' '.

아바타
취소
베스트 답변

Try to set the function storable.

_columns = {
         'is_green': fields.function(_is_green, type = 'boolean', store=True),
         'is_orange': fields.function(_is_orange, type = 'boolean', store=True),
         'is_red': fields.function(_is_red, type = 'boolean', store=True),
           }
아바타
취소
관련 게시물 답글 화면 활동
2
7월 21
17642
1
3월 15
6383
6
1월 19
9521
3
4월 17
10570
1
3월 15
4947