Skip to Content
Menu
This question has been flagged
7839 Views

Hi,

I'm trying to add a custom html code in my view :

<table>
      <tr>
        <td><div class="customDiv">Div1</div></td>
        <td><div class="customDiv">Div2</div></td>
        <td><div class="customDiv">Div3</div></td>
      </tr>
      <tr>
        <td><div class="customDiv">Div4</div></td>
        <td><div class="customDiv">Div5</div></td>
        <td><div class="customDiv">Div6</div></td>
      </tr>
</table>


I have a field "level_mask" (type Float) in my model. It is a bit mask.

I want to do the mapping between the bits in level_mask and my DIVs in the view. Example :

level_mask = 7 (dec) = 000111 (bin) -->  So, div1, div2, div3 will be with green color and div4, div5, div6 will be red.

I did create new template in custom.xml (t-name="customWidget") containing the html code above and create custom.js :

openerp.custom = function(instance, local) {
    console.log('customWidget', instance)
    instance.web.form.widgets = instance.web.form.widgets.extend({
        'customWidget': 'instance.web.form.message',
    });
    instance.web.form.message = instance.web.form.FieldChar.extend({
        template: 'customWidget',
        start: function() { $('div.customDiv').click(this.show_message); },
        show_message: function() {
            alert('should toggle color here');
        }
    });
}

I have these questions :

- How can I add a member to the model class that contains a list of six boolean (their values are computed from level_mask) that will be used in my view ?

- How can I use the list of boolean in my view to set the color of  each div ?


Thanks for answers in advance.

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 21
2831
2
Dec 20
9604
0
Mar 15
2846
0
Feb 24
433
0
Jan 24
402