Odoo Help


dynamic template for list views

Peter Nietz
on 1/24/14, 4:40 PM 5,109 views

Hi Guys,

the goal is to customize a List View <tree> that changes the background colour of a specific cell if a Key/Value Pair is matched. So I tried to write my own template for the ListView in static/src/js and xml, which I copied out of the web module template, and add my own Javascript into my view_list.js, also from the web module, included my attf condition to the xml, added the paths to __openerp__.py

But now every List in OpenErp changes colors (css classes) so in Details:

got the ListView Template from /usr/lib/pymodules/python2.7/openerp/addons/web/static/src/xml/base.xml

<templates id="template" xml:space="preserve">


<table t-name="ListView" class="oe_list_content">

<t t-set="columns_count" t-value="visible_columns.length + (options.selectable ? 1 : 0) + (options.deletable ? 1 : 0)"/>`


and then to the :

        <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>

-added THIS -->>>

#{value_check(record.get(column.id), column.id) ? 'oe_custom_view' : 'oE_3o'}

The /addons/web/static/src/js/view_list.js is exactly the same but I added:

value_check: function (value, key) {
  return ((key=="name") && (value=="test"));

so the condition can be matched.

So everything works so far but instead of only turning the cell colors of my module, every list view in open erp is changed.

Did I overwrote that by not changing the js or xml names and attributes?

How can I fix this so only my own view is affected?



Peter Nietz
On 7/15/14, 12:07 PM

At  http://doc.openerp.com/trunk/web/qweb/   I found this:

t-extend=template BODY


template (String) -- name of the template to extend

Works similarly to OpenERP models: if used on its own, will alter the specified template in-place; if used in conjunction with t-name will create a new template using the old one as a base.

But if i add a t-name like

<t t-extend="givenView" t-name="myView">

my custom template isn't used anymore. How do I tell openERP to use my CustomTemplate instead of the standard?


so I tried a different approach and got the solution here:


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 1/24/14, 4:40 PM
Seen: 5109 times
Last updated: 3/16/15, 8:10 AM