← Back to team overview

openerp-community team mailing list archive

Re: Solution/Example for displaying icons in a Tree View (OpenERP 6.1)?

 

Hello,

Did you find a way to fix this problem?

I also got the same problem when trying to display an image in the tree
view base on the value of the record. Below is what i did to fix it:

   1. In the xml file, use a new widget "my_new_widget" for the field which
   I want to display the image

<field name="day_1" widget="my_new_widget"/>
>

   1. In the function "openerp.web.format_cell" of the file
   web/addons/web/static/src/js/formats.js, add source code to handle my new
   widget.

case 'progressbar':
>         return _.template(
>             '<progress value="<%-value%>"
> max="100"><%-value%>%</progress>', {
>                 value: row_data[column.id].value
>             });
>
> case 'my_new_widget':
>     var data = row_data[column.id];
>     var src_image = '/web/static/src/img/icons/available.png';
>     if (data === 'case1') {
>         src_image = '/web/static/src/img/icons/case1.png';
>     } else if (data === 'case2') {
>         src_image = '/web/static/src/img/icons/case2.png';
>     }
>     return _.str.sprintf('<img src="%s"/>', src_image);
>

Hope that help ;)

Regards,
Tu Bui
Technical Project Manager - Trobz
Web: www.trobz.com




On Tue, Jul 3, 2012 at 10:11 PM, Sven Petersen <s.petersen@xxxxxxxxxx>wrote:

> Hello again,
>
> well there is a render_cell function in web/static/src/js/view_list.js of
> the webclient, but honestly I’m not sure if this would be the right place
> to start for rendering an image?
>
> I would be happy for suggestions!
>
> thank you!****
>
> ** **
>
> *Von:* Sven Petersen
> *Gesendet:* Donnerstag, 28. Juni 2012 12:01
> *An:* Sven Petersen; Niels Huylebroeck
> *Cc:* openerp-community@xxxxxxxxxxxxxxxxxxx
> *Betreff:* AW: [Openerp-community] Solution/Example for displaying icons
> in a Tree View (OpenERP 6.1)?****
>
> ** **
>
> Hello,
>
> the Web Client seems to ignore widget="image" in Tree Views, so that
> doesn’t work.****
>
> Any other Ideas? (except waiting for v7 and playing around with jquery? J)
>
> thanks!****
>
> ** **
>
> *Von:* openerp-community-bounces+office=conexus.at@xxxxxxxxxxxxxxxxxxx
> [mailto:openerp-community-bounces+office=conexus.at@xxxxxxxxxxxxxxxxxxx] *Im
> Auftrag von *Sven Petersen
> *Gesendet:* Mittwoch, 27. Juni 2012 14:21
> *An:* Niels Huylebroeck
> *Cc:* openerp-community@xxxxxxxxxxxxxxxxxxx
> *Betreff:* Re: [Openerp-community] Solution/Example for displaying icons
> in a Tree View (OpenERP 6.1)?****
>
> ** **
>
> I’ll try that. Thank you!****
>
> ** **
>
> *Von:* Niels Huylebroeck [mailto:nh@xxxxxxxxxx]
> *Gesendet:* Mittwoch, 27. Juni 2012 14:17
> *An:* Sven Petersen
> *Cc:* Eric Caudal; openerp-community@xxxxxxxxxxxxxxxxxxx
> *Betreff:* Re: [Openerp-community] Solution/Example for displaying icons
> in a Tree View (OpenERP 6.1)?****
>
> ** **
>
> ** **
>
> 2012/6/27 Sven Petersen <s.petersen@xxxxxxxxxx>****
>
> Thank you for your answer, but I’m in need of displaying custom icons
> according to a field value of a record line.
> So far icons can only be set for buttons, or am I wrong?****
>
>
> Not sure if this will work but what about showing a fields.binary with
> widget="image" on your tree form ?
> It would require you to "store" the images inside the database though
> (only once if you use a functional field to fetch values on the fly)****
>
>
> --
> Niels Huylebroeck
> Lead Architect   --   Agaplan****
>
> Tel. : +32 (0) 93 95 98 90****
>
> Web : http://www.agaplan.eu****
>
> ** **
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to     : openerp-community@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openerp-community
> More help   : https://help.launchpad.net/ListHelp
>
>

Follow ups

References