Community: Framework mailing list archives

expert-framework@mail.odoo.com

javascript inside <form> element of form view

by
Maxim Litnitskiy
- 09/21/2014 09:23:45
Hi dear Experts!
Can some one give a clue why the following works:

            <form string='Campaign' edit='1'>
                <script type='text/javascript'>
                    alert('bla-bla');
                </script>

and the following does not work:

            <form string='Campaign' edit='1'>
                <script type='text/javascript'>
                    $("button.oe_button.oe_form_button_edit").hide();
                </script>


??

I am trying to add functionality to hide / show edit / create / delete buttons of form view based on conditions.
As far as I understood we cannot do it directly as first xml arch is loaded and then it is populated with fields data.
So we cannot do smth like <form string='Campaign' attrs="{'edit': [('state', '=', 'can_edit')]}"/>.
So I thought I can do it why JQuery after load.
Seems not?
Thanks.