0

I have a popup window (form) and a button on it, in OpenERP, picture attached. When I click on the button (for now it does nothing) my form is closed. I want to leave it open after the button click. How can I do that? I am aware of "nodestroy"=True, but I am not sure where to put it, if it is solution.

enter image description here

Here is my XML code:

<record id="replace_all_in_BOM_form" model="ir.ui.view">
    <field name="name">replace.all.in.BOM.form</field>
    <field name="model">product.template</field>
    <field name="priority" eval="20"/>
    <field name="type">form</field>
    <field name="arch" type="xml">
        <label class="text-inline" for="original_name" string="Original" 
        ></label>
        <input name="original_name" id="original_id" ></input>
        <group>
            <field name="default_code" string="Replacement" readonly="1" 
            invisible="0" />    
            <field name="uom_id" invisible="1"  /> 
            <field name="uom_po_id" invisible="1"   />
            <field name="type" invisible="1"   />   
            <field name="categ_id" invisible="1"   /> 
            <field name="name" invisible="1" />             
        </group>
            <button type="object" string="Replace" name="action_replace" />
    </field> 
    </record>

<record id="action5" model="ir.actions.act_window">
    <field name="name">Replace all in BOM</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">product.template</field>           
    <field name="view_type">form</field>
    <field name="target">new</field>
    <field name="view_id" ref="replace_all_in_BOM_form"/>
</record>

<record id="ir_BOM_structure5" model="ir.values">
    <field eval="'client_action_multi'" name="key2"/>
    <field eval="'product.template'" name="model"/>
    <field name="name">Replace all in BOM</field>
    <field eval="'ir.actions.act_window,'+str(action5)" name="value"/>
</record>
SmithMcPatrick
  • 599
  • 5
  • 18
  • 33

1 Answers1

1

You have to return an action that re-open the same pop-up.

To do that, the 'action_replace' method should return:

return {
    'type': 'ir.actions.act_window',
    'res_model': 'your.model',
    'view_type': 'form',
    'view_mode': 'form',
    'res_id': 'id_of_the_wizard',
    'target': 'new',
}
Quentin THEURET
  • 1,222
  • 6
  • 12
  • I have already tried that, but thank you for your answer. The issue with this approach is when the window is reopened the values "Original" and "Replacement" are lost. I would like to keep these values on the form after the button click. – SmithMcPatrick Jan 23 '15 at 16:53
  • @Nash: for that make a new field and enter value in it when action_replace button is press. New field will store previous value and add comma separator after value insert. You may keep track of it's value. Button will return TRUE so pop-up window keep alive. Thanks – Bhavesh Odedra Jan 24 '15 at 08:07
  • @Odedra Thanks Odedra. When I make a new field, does it mean it will be added to some table? How I can add a field, can you give a code example? Thanks – SmithMcPatrick Jan 24 '15 at 22:57
  • This may be find helpful: https://stackoverflow.com/questions/31963214/odoo-prevent-button-from-closing-wizard – Nikhil Mohan Dec 12 '17 at 10:11