Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

inherit/extend ListView.row from base.xml

By
Peter Nietz
on 3/21/14, 1:48 PM 3,717 views

I wanna extend the ListView.row in the web module base.xml Line:770

<tr t-name="ListView.row"
        t-att-data-id="record.get('id')"
        t-att-style="view.style_for(record)">
    <t t-set="asData" t-value="record.toForm().data"/>
    <t t-foreach="columns" t-as="column">
        <td t-if="column.meta"> </td>
    </t>
    <th t-if="options.selectable" class="oe_list_record_selector" width="1">
        <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"/>
        <input t-if="!options.radio" type="checkbox" name="radiogroup" t-att-checked="checked"/>
    </th>
    <t t-foreach="columns" t-as="column">
        <t t-set="number" t-value="column.type === 'integer' or column.type == 'float'"/>
        <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="oe_list_field_cell oe_list_field_#{column.widget or column.type} 
                         #{number ?  'oe_number' : ''} 
                         #{column.tag === 'button' ? 'oe-button' : ''} #{modifiers.readonly ? 'oe_readonly' : ''} 
                         #{modifiers.required ? 'oe_required' : ''} "
            t-att-data-field="column.id"
            ><t t-raw="render_cell(record, column)"/></td>
    </t>
    <td t-if="options.deletable" class='oe_list_record_delete' width="13px">
        <button type="button" name="delete" class="oe_i">d</button>
    </td>
</tr>

So I can add some code to the 't-attf-class' of the td element. But my approaches didnt work:

<templates>
<tr t-extend="ListView.row">
    <t t-jquery="td" t-operation="replace">
        <td t-if="!column.meta and column.invisible !== '1'" t-att-title="column.help"
            t-attf-class="oe_list_field_cell oe_list_field_#{column.widget or column.type} 
            #{number ?  'oe_number' : ''} 
            #{column.tag === 'button' ? 'oe-button' : ''} #{modifiers.readonly ? 'oe_readonly' : ''} 
            #{modifiers.required ? 'oe_required' : ''} 
            #{value_check(record.get(column.id), column.id) ? 'oe_custom_view' : 'oE_3o'}"
            t-att-data-field="column.id">
            <t t-raw="render_cell(record, column)"/>
        </td -->
    </t>
</tr>
</templates>

OpenErp tells me that it doesn't know the "column".

Any suggestions?

1
Peter Nietz
On 4/10/14, 8:40 AM

OK, I solved it: these lines

<t t-foreach="columns" t-as="column">
<t t-set="number" t-value="column.type === 'integer' or column.type ==   'float'"/> <t t-set="modifiers" t-value="column.modifiers_for(asData)"/>

are also needed and must be included in the inherited template so it knows the "column" like this:

<templates>
<tr t-extend="ListView.row">
<t t-jquery="td" t-operation="replace">
<t t-foreach="columns"   t-as="column">
<t t-set="number" t-value="column.type === 'integer' or column.type == 'float'"/>
<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="oe_list_field_cell oe_list_field_#{column.widget or column.type} #{number ? 'oe_number' : ''} #{column.tag === 'button' ? 'oe-button' : ''} #{modifiers.readonly ? 'oe_readonly' : ''}  #{modifiers.required ? 'oe_required' : ''} #{column.value_check(record.get(column.id), column.id) ? 'oe_cust_view' : ''}" t-att-data-field="column.id">
<t t-raw="render_cell(record, column)"/>
</td >
</t>
</t>
</tr>
</templates>

To call a custom JS function like "value_check" and not get something like:

dict.value_check is not a function

take a look at:

http://www.odoo.com/forum/Help-1/question/cannot-call-custom-JS-from-inherited-qweb-template-49260

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/21/14, 1:48 PM
Seen: 3717 times
Last updated: 3/30/16, 5:57 AM