Odoo Help


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.


dynamic template for list views

Peter Nietz
on 1/24/14, 4:40 PM 3,413 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:


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)


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