Search code examples
colorstreeviewodoo-8uid

Odoo get groups from uid


I have a tree view and I want to define the color of the lines depending of the value of the field payments_state. This work fine. But I want to check if the user is in the group group_member_manage also to define the color.

<?xml version="1.0"?>
               <tree colors="red:payments_state == 'nok' and uid.has_group('member_management.group_member_manage')">
                    <field name="title"/>
                    <field name="name"/>
                    <field name="since_date"/>
                    <field name="phone"/>
                    <field name="mobile"/>
                    <field name="contributions" invisible="True"/>
                    <field name="payments_state" groups="member_management.group_member_manage"/>
                </tree>

When I go on the view I have this error:

Uncaught Error: QWeb2 - template['ListView.rows']: Runtime Error: Error: QWeb2 - template['ListView.row']: Runtime Error: Error: AttributeError: object has no attribute 'has_group'

Someone have a list of all method of the uid attribute? Someone have an idea to resolve my problem?


Solution

  • I found the solution:

    I created a computed field which check the right of current user. Then I used it in XML view