Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2944 Zobrazení

hi all,

I have two check box(boolean). If i click one "check box1". second "check box2" should hide and vice verse should happen.

Or if i click "check box1" and if i try to click on "check box2" it should call onchange method/pop-up error message should show. 

How to do this. Please help.

Thanks in advance

Avatar
Zrušit
Nejlepší odpověď

<div attrs="{'invisible': [('bbb', '=', True)]}>
    <field name="aaa"/>
</div>
<div attrs="{'invisible': [('aaa', '=', True)]}">
    <field name="bbb"/>
</div>

Avatar
Zrušit
Autor

Thank you zbik it worked

Please do not take this as an offence. This is correct and should work perfectly but imho this is not a great solution to the problem, since it only works on the view level. Anyone importing data for example will still be able on the database to set both fields to true. If there is only one value ever valid, then I would suggest going for a list or something similar. This only ever allows you to select 1 of the values.

Autor

thanks ludo i got your point. can we show a pop-up error message when we select another check box. how to write that "onchange" method. please help. thanks

This link should help you: https://www.odoo.com/forum/help-1/question/raise-an-error-in-odoo-8-70152#answer-70159 You replace def FOO(self) by: def onchange_FOO(self,aaa,bbb) and return result like this: result = {'value': { 'aaa': True, 'bbb': False, }}