This question has been flagged
2 Replies
13257 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?

ThX

Peter

Avatar
Discard
Author Best Answer

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

t-extend=template BODY

Parameters:

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:

https://www.odoo.com/forum/help-1/question/why-does-my-qweb-inheritance-affect-the-base-module-from-which-i-inherit-54709

Avatar
Discard
Best Answer

HI, you can follow following tutorial for this:

https://youtu.be/kwkddYoFQCE

Hope it helps,

Thanks

Avatar
Discard