Odoo Help

1

1
4 Answers
1
Antuan Cuba
05:37, 09/01/2017

Hi Dhinesh,

I have tried your code but does not work for me. Currently I am using this approach that adds the class property at td level, but what I want is to add it at tr level:


<t t-extend="ListView.row">
  <t t-jquery="td[t-att-data-field='column.id']">
  this.attr('t-attf-class', this.attr('t-attf-class') + ' #{view.class_for(record)}');
  </t>
</t>
1
Fatih Piristine Finland
13:51, 24/07/2017

try this one. if not working, dig into manual deeper from v7.

<t t-extend="ListView.row">
<xpath expr="//tr[@t-name='Listview.row']" position="attributes">
<attribute name="t-att-class">view.class_for(record)</attribute> <xpath>
</t>
0
DenisK Germany
04:42, 09/04/2019

Its a litte bit late but maybe it will help someone who is also stumbling over this topic.

I'm using the following code to add custom CSS to the rows and to the cells:

<t t-extend="ListView.row">
    <t t-jquery="tr">
        this.context.setAttribute('t-att-class', 'view.class_for(record)');
    </t>
  <t t-jquery="td[t-att-data-field='column.id']">
      this.attr('t-attf-class', this.attr('t-attf-class') + ' {{view.class_for_cell(record, column)}}');
  </t>
</t>

The method "class_for_cell" is an own function to extract the information from the field and set the specific class to the cell.

Working with V8.

0
Avatar

Dhinesh India

--Dhinesh--
3935
| 6 5 11
Pondicherry, India
--Dhinesh--

Stack: Python/Odoo/AWS/Redis/Linux/Nginx/Docker/Django/Eclipse

Dhinesh India
14:47, 13/12/2016

Hi,

You can just use the Qweb Js inheritance by extending the t-name and adding the new class like below:

<?xml version="1.0" encoding="UTF-8"?>
<templates>
    <t t-extend="ListView.row">
        <t t-jquery="tr[t-att-data-id*='record.get('id')']">
            this.attr('t-attf-class', this.attr("t-attf-class") + 'view.class_for(record)');
        </t>
    </t>
</templates>
Ask a Question
Writer
Keep Informed
2 follower(s)
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.

Register
Odoo Training Center

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

Test it now