1

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?

Kenly
  • 24,317
  • 7
  • 44
  • 60
Döme
  • 835
  • 11
  • 23
  • when would you like the button to appear? and on what condtion? – WhatsThePoint Feb 01 '17 at 10:37
  • @WhatsThePoint Honestly, never want to show 'Save' and 'Discard' buttons on this form. So I have no condition for that. I want to use own button, with own place definition and own function. TL;DR --> Fully custom form view is what I want. And this is one step. – Döme Feb 01 '17 at 11:39
  • not a great fix but you could put your own buttons infront of them? – WhatsThePoint Feb 01 '17 at 11:43
  • @WhatsThePoint No. I want to hide both of default buttons what from odoo framework. I will use my button. Perhaps you will understand better when I add its definition to xml source of my question. Is it clear? – Döme Feb 01 '17 at 12:07
  • does this question help at all? http://stackoverflow.com/questions/35196277/how-to-hide-edit-create-button-on-form-by-conditions – WhatsThePoint Feb 01 '17 at 12:41
  • (When I wrote my last answer, I didn't see the so link in your answer. Sorry about it.) Unfortunately, this is not helpful for me. – Döme Feb 01 '17 at 12:54
  • how about this one? http://stackoverflow.com/questions/39598670/how-to-remove-savenew-button-from-popup-in-odoo – WhatsThePoint Feb 01 '17 at 13:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/134593/discussion-between-whatsthepoint-and-dome). – WhatsThePoint Feb 01 '17 at 13:32

2 Answers2

3

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!

Alpesh Valaki
  • 1,611
  • 1
  • 16
  • 36
0

To complete the last answer, if you need a simple "CLOSE" button:

<button data-dismiss="modal" string="Close"/>
Koul
  • 77
  • 1
  • 9