Search code examples
pythonxmlodoo-10

How to hide save button on popup form?


How to hide save button on popup form?*

The form view opened by action in python code. I already tried some recommended solution, but their doesn't work.

Some portal/forum said this flags will be solve it. But it don't, what even more, it has not any effect to behavior. (anyway, where can I read from flags? I can't find any useful description about it.)

@api.multi
def button(self):
    viewId = self.env.ref('Model.model').id
    return {
        'name': _('Button action'),
        'view_type': 'form',
        'view_mode': 'form',
        'view_id': viewId,
        'res_model': 'model',
        'type': 'ir.actions.act_window',
        'res_id': self.id,
        'target': 'new',
        'flags': {'form': {'action_buttons': False}}
    }

The most place said this is the right way, but it does not work...

<record id="model" model="ir.ui.view">
        <field name="name">model</field>
        <field name="model">model</field>
        <field name="arch" type="xml">
            <form string="Button form" edit="false" create="false" delete="false">
                <group>
                    <field name="test" />
                    <button name="myButtonFunc" string="Demo button" icon="fa-plus" type="object"/>
                </group>
            </form>
        </field>
    </record>

Any idea? Or experience with it?


Solution

  • To hide default button of wizard you need to replace footer of wizard. see following example of view.xml

    <record id="test_models_wizard" model="ir.ui.view">
            <field name="name">test.models.form</field>
            <field name="model">test.models</field>
            <field name="arch" type="xml">  
                <form string="Test Wizard">
                    <group>
                        <group>
                            <field name="test_field_1"/>
                            <field name="test_field_2"/>
                        </group>
                    </group> 
                    <footer>
                        <button name="your_test_method" string="My Button" type="object" class="btn-primary"/> 
                        <button string="Cancel" class="btn-default" special="cancel"/>   
                    </footer>
                </form>
            </field>
        </record>
    

    add your desired button in between footer tag!