odoo16裏面修改tree視圖樣式

一、在static文件夾下新建一個css文件夾並將*.css文件寫入

/*該文件用來定義視圖中的一些格式,需要用到的地方直接在xml文件中進行引用*/
/*語法說明*/
/*
table th:nth-child(1)  代表定位到table 的 th上面到第一個th標題
nth-child()參考 css語法http://www.w3school.com.cn/cssref/css_selectors.asp
:nth-child(1) 表示 第1個元素
:nth-child(even) 表示 偶數
:nth-child(odd) 表示 奇數
:表示所有(未在od中測試)
*/
/*
!important  作用是權重作用  權重最大,樣式有優先級
*/


/*樣式 樹形列表中所有標題居中  這裏利用奇數和偶數都居中的語法 *
/*樣式 樹形列表中元素p根據序數進行標題居中設置*/
.melon_fix_width_tree_style_p1 table th:nth-child(even) {
    width:200px !important;
    /*background-color: red !important;*/
}
.melon_fix_width_tree_style_p1 table th:nth-child(odd) {
    width:200px !important;
    /*background-color: #3168a7 !important;*/
}

 

二、在xml的tree上定義一個class

  <!-- tree視圖 -->
        <record id="view_melon_execute_detail_tree" model="ir.ui.view">
            <field name="name">melon_execute_detail_tree</field>
            <field name="model">melon_execute_detail</field>
            <field name="arch" type="xml">
                <tree string="無極執行明細" create="0" class="melon_fix_width_tree_style_p1">
                         <field name="short_sz" optional="show" width="200px"/>
                </tree>
            </field>
        </record>

 

三、最重要一步是在__manifest__文件裏面寫入

    'assets': {
        'web.assets_backend': [
'your_model/static/src/css/base.css',
        ],
    },

 

然後升級模型即可看到效果

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章