Odoo-使用colspan查看自定义或可能是col [英] Odoo - View customization with colspan or may be col

查看:96
本文介绍了Odoo-使用colspan查看自定义或可能是col的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用odoo 10-e.早些时候我问一个问题,我们如何合并两个或多个标题以针对多个字段显示一个标题 将两个字段合并为一个one2many .因此,答案是好的,并且奏效了,但现在我想在one2many树形视图中进行更多自定义.我想要这样的东西.

I am using odoo 10-e . Earlier i asked a question how can we merge two or multiple header to show one header against multiple fields Combine two fields heading in one2many . So answer was good and it worked but now i want to do some more customization in the one2many tree view in form. I want something like this.

我也希望行中有边框,但要有特定的列,而且子标题每列只能有一次.

I want borders also in rows but for specific columns and also sub heading for only once per column.

我尝试在odoo视图中添加div,但不支持.我也尝试将其添加到组中,但是那也行不通.

I tried to add div in odoo view but its not supported. I also tried to add it under groups but that is also not working.

推荐答案

将以下代码添加到同一文件 colspan.xml

Add below code to the same file colspan.xml Combine two fields heading in one2many as i given answer of it.

就是这样,您可以在添加 conspan 时使用 subheading col_border 属性.

And that's it you can use subheading and col_border attribute as i added conspan.

<field name="one2manyfield">
    <tree>
      <field name="field1" subheading="SubHeading"/>
      <field name="field2" col_border="1"/>
    </tree>
</field>

要添加到colspan.xml中的代码

 <t t-name="ListView.rows" >
        <t t-set="first_column" t-value="1"/>
        <t t-foreach="records.length" t-as="index">
            <t t-call="ListView.row">
                <t t-set="record" t-value="records.at(index)"/>
            </t>
            <t t-set="first_column" t-value="0"/>
        </t>
    </t>

    <tr t-name="ListView.row"
            t-att-data-id="record.get('id')"
            t-attf-style="#{(view.fonts || view.colors) ? view.style_for(record) : ''}"
            t-attf-class="#{view.compute_decoration_classnames(record)}">
        <t t-set="asData" t-value="record.toForm().data"/>
        <t t-foreach="columns" t-as="column">
            <td t-if="column.meta"> </td>
        </t>
        <td t-if="options.selectable" class="o_list_record_selector">
            <t t-set="checked" t-value="options.select_view_id == record.get('id') ? 'checked' : null"/>
            <input t-if="options.radio" type="radio" name="radiogroup" t-att-checked="checked"/>
            <div t-if="!options.radio" class="o_checkbox">
                <input type="checkbox" name="radiogroup" t-att-checked="checked"/><span/>
            </div>
        </td>

        <t t-foreach="columns" t-as="column">
            <t t-set="number" t-value="column.type === 'integer' or column.type == 'float' or column.type == 'monetary'"/>
            <t t-set="text" t-value="column.type === 'text'"/>
            <t t-set="modifiers" t-value="column.modifiers_for(asData)"/>
            <td t-if="!column.meta and column.invisible !== '1'" t-att-title="column.help"
                t-attf-class="#{modifiers.readonly ? 'o_readonly' : ''} #{number ? 'o_list_number' : ''} #{text ? 'o_list_text' : ''} #{column.id === 'sequence' ? 'o_handle_cell' : ''} #{column.tag === 'button' ? 'o_list_button' : ''}"
                t-att-style="column.col_border === 1 ? 'border-left:1px solid black!important;border-right:1px solid black!important' : ''"
                t-att-data-field="column.id"

                >
                <t t-if="!column.subheading or first_column === 0">
                    <t t-raw="render_cell(record, column)"/>
                </t>
                <t t-if="first_column === 1 and column.subheading">
                    <div class="text-center"><span><b><t t-esc="column.subheading"/></b></span></div><br/><t t-raw="render_cell(record, column)"/>
                </t>


                </td>
        </t>
        <td t-if="options.deletable" class='o_list_record_delete'>
            <span name="delete" class="fa fa-trash-o"/>
        </td>
    </tr>

这篇关于Odoo-使用colspan查看自定义或可能是col的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆