Search code examples
odoo-12

How to add selected customer image in Odoo POS v12


I'd like to add the selected customer image on the left of his name and replace the fa-user icon. I've tried to use

<t t-if='widget.pos.get_client().image'>
    <img t-att-src='widget.pos.get_client().image' alt="widget.pos.get_client()"/>
</t>

with "widget.pos.get_client().image" to call image in pos.xml and declare it in model.js

get_image: function() {
    return this.image;
},

but image value is always null.

Does anyone know how to get the selected customer image ?

thx for your help


Solution

  • In JS //

    screens.ActionpadWidget.include({
            partner_icon_url: function(id){
                 return '/web/image?model=res.partner&id='+id+'&field=image_small';
        },
        });
    

    In XML // inherit the view and this line.

    <t t-extend="ActionpadWidget">
            <t t-jquery="i[class='fa fa-user']" t-operation="replace">
                 <div class='client-picture' style="height: 50px;width: 50px;">
                    <img t-att-src='widget.partner_icon_url(partner.id)' alt="Partner logo"/>
                </div>
            </t>
    
    </t>