Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
8624 Ansichten

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
März 21
3741
2
Dez. 20
10645
0
März 15
3742
0
Apr. 25
1399
0
Jan. 24
1556