3

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.

enter image description here

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.

Ancient
  • 3,007
  • 14
  • 55
  • 104

1 Answers1

2

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>
Chavada Viki
  • 1,514
  • 1
  • 12
  • 22
  • where should i add this in colspan.xml ? – Ancient Aug 02 '17 at 12:02
  • will this also work for one2Many inline edit form view ? – Ancient Aug 02 '17 at 12:45
  • 1
    Well, thanks a lot it worked for me. Really appreciate your effort. If you got enough time can you please explain this because its working but i didn't know how and also may be it will help future users. – Ancient Aug 02 '17 at 13:04
  • Sure. i will try my best. – Chavada Viki Aug 02 '17 at 14:02
  • I am facing a issue, In my one2many grid i have enabled inline edit `editable=bottom` and when i click on edit to change some and save it every thing gets hidden on that particular columns on which the custom attributes are attached. Can you help me out ? – Ancient Aug 02 '17 at 16:00