Odoo-将两个字段的标题合并为一个 [英] Odoo - Combine two fields heading in one2many
本文介绍了Odoo-将两个字段的标题合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用odoo 10-e.我创建了自定义模块,并在该模块中显示了这样的一个记录
I am working with odoo 10-e. I created custom module and in that module i want to show one2many records like this
----------------
| Long Cell |
----------------
| 1 | 2 |
----------------
现在,默认情况下
每列都有其自己的标题,该标题实际上是string=
值.我想覆盖默认行为.
right now by default each column have its own heading which is actually string=
value. I want to override default behavior.
推荐答案
首先创建xml文件,该文件将像这样扩展ListView模板,以在基本列表视图模板中添加colspan功能.
First create the xml file which extends the ListView Template like this to add colspan feature in base list view template.
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中.
You can use colspan in any field. in Listview.
例如.
<tree>
<field name="any_field" colspan="2"/>
</tree>
尝试一下.
我希望这对您有用.
这篇关于Odoo-将两个字段的标题合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文