2017-07-28 107 views
1

我正在使用odoo 10-e。我創建的自定義模塊和模塊中我想告訴one2many這樣Odoo - 在one2many中組合兩個字段

---------------- 
| Long Cell | 
---------------- 
| 1 | 2  | 
---------------- 

記錄現在默認每列有它自己的標題實際上是string=值。我想覆蓋默認行爲。

+0

你想要的功能就像在html表中爲colspan的odoo listview。對 ? –

回答

4

首先創建擴展ListView模板的xml文件,像這樣在基本列表視圖模板中添加colspan特徵。

colspan.xml

<?xml version="1.0" encoding="UTF-8"?> 
<templates id="template" xml:space="preserve"> 
<div t-extend="ListView"> 
    <t t-jquery="table" t-operation="replace"> 
     <table class="o_list_view table table-condensed table-striped"> 
     <t t-set="columns_count" t-value="visible_columns.length + (options.selectable ? 1 : 0) + (options.deletable ? 1 : 0)"/> 
     <thead> 
      <tr t-if="options.header"> 
       <t t-foreach="columns" t-as="column"> 
        <th t-if="column.meta"> 
         <t t-esc="column.string"/> 
        </th> 
       </t> 
       <th t-if="options.selectable" class="o_list_record_selector" width="1"> 
        <div class="o_checkbox"> 
         <input type="checkbox"/><span/> 
        </div> 
       </th> 
       <t t-set="col" t-value="0"/> 
       <t t-foreach="columns" t-as="column"> 
        <t t-if="col == 0"> 
        <th t-if="!column.meta and column.invisible !== '1'" t-att-data-id="column.id" 
         t-attf-class="text-center #{((options.sortable and column.sortable and column.tag !== 'button') ? 'o_column_sortable' : '')}" 
          t-att-width="column.width()" t-att-colspan="column.colspan" > 
         <t t-set="col" t-value="column.colspan or 1"/>  
         <t t-if="column.tag !== 'button'"><t t-raw="column.heading()"/></t> 
        </th> 
        </t> 
        <t t-if="col !== 0" t-set="col" t-value="col - 1"/> 
       </t> 
       <th t-if="options.deletable" class="o_list_record_delete"/> 
      </tr> 
     </thead> 
     <tfoot> 
      <tr> 
       <td t-if="options.selectable"/> 
       <td t-foreach="aggregate_columns" t-as="column" t-att-data-field="column.id" t-att-title="column.label"> 
       </td> 
       <td t-if="options.deletable" class="o_list_record_delete"/> 
      </tr> 
     </tfoot> 
    </table> 
    </t> 
</div> 
</template> 

添加在__manifest__.py

... 
'qweb': [ 
     "static/src/xml/colspan.xml", 
    ], 
... 

就是這樣。

您可以在任何領域使用colspan。在ListView中。

例如,

<tree> 
    <field name="any_field" colspan="2"/> 
</tree> 

試試吧。

我希望這會對你有用。

+0

我得到這個錯誤:'odoo.tools.convert:XML文件不符合所需的模式' – Ancient

+0

其實這是我的錯。現在它的工作很完美。非常感謝 – Ancient

+0

你能幫助我多一點,讓我知道我在odoo文檔中找到的以上內容。我的意思是,這是定義任何地方如何定製像這樣 – Ancient

相關問題