Odoo - View customization with colspan or may be col

不羁的心 提交于 2019-12-08 04:45:03

问题


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.

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.


回答1:


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

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>

Code to add in 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>


来源:https://stackoverflow.com/questions/45444767/odoo-view-customization-with-colspan-or-may-be-col

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!