Odoo Help

Welcome!

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.

1

How do I get the user avatar in the kanban view of a custom module?

By
Erick Dyck
on 10/1/13, 4:29 AM 2,663 views

Hey guys, I'm trying to create a custom module and every thing works fine so far. My only problem is, that I'm not able to show the user avatar in the kanban view. I only get a randow image (maybe my function is wrong?) I trying to get the user avatar from res.partners.

Here the pythonscript:

def _get_user_image(self, cr, uid, ids, field, arg, context=None):
        res = {}
        ctx = {}
        records = self.browse(cr, uid, ids, context=context)
        for record in records:
            res[record.id] = record.user_id.pool.get('res.partner')._get_default_image(cr, uid, False, ctx, colorize=True)
        return res

#...

_columns    = {
        'image'     : fields.function(_get_user_image, type="binary", method=True, string='Image', readonly=True),
    }

The view.xml

<record model="ir.ui.view" id="view_gcon_access_kanban">
    <field name="name">gcon.access.kanban</field>
    <field name="model">gcon.access</field>
    <field name="arch" type="xml">
        <kanban>
            <field name="user_id"/>
            <field name="name"/>
            <field name="count_contact"/>
            <field name="count_devices"/>
            <field name="image"/>
            <templates>
                <t t-name="kanban-box">
                    <div class="oe_kanban_vignette oe_semantic_html_override">
                        <a type="open">
                             <img t-att-src="kanban_image('gcon.access', 'image', record.id.value)" class="oe_kanban_image"/>
                        </a>
                        <div class="oe_kanban_details">
                            <h4>
                                <a type="open">
                                    <field name="user_id"/> (<field name="name"/>)
                                </a>
                            </h4>
                            <group>
                                Contacts: <field name="count_contact"/><br />
                                Devices: <field name="count_devices"/>
                            </group>
                        </div>
                    </div>
                </t>
            </templates>
        </kanban>
    </field>
</record>

What of these codes is wrong? In the xml I tried several tag, but nothing worked or rather displayed the wrong image. We are using the openERP v7. Best regards

Dyck

3
Erick Dyck
On 10/1/13, 5:52 AM

I have found a solution. I used following tag to get the user avatar:

<img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" class="oe_kanban_image"/>

Best Regards

Dyck

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)

Stats

Asked: 10/1/13, 4:29 AM
Seen: 2663 times
Last updated: 3/16/15, 8:10 AM