Skip to Content
Menu
This question has been flagged
4 Replies
17668 Views


Hello friends!!!

Please, i have a button that opens a pop up.

The problem here is that after creating records in that popup and saving.

It will not close automatically the popup depspite the fact in an other case it will disappear (close).

So, my question is how to control my pop up when i want to close it automatically after clicking on save it will be close and when i want to let open it will appear.

Please help really need an answer.

Thanks and regards.

Avatar
Discard
Best Answer

The default behavior for wizard buttons (button  type="object) as of OpenERP is to immediately close the wizard.

The method called by the button can return an action definition dictionary that will be executed.

When you do not want the wizard to close it is usually because you have several steps. As multi-steps wizards usually have different form views, their button methods simply return actions to open the same wizard record using the next step's view or another view.

Avatar
Discard
Author

Thanks for the answer but i didnt understand how to manage it please

Author Best Answer

Thanks for the answer friend.

Here is my code:

def edit_data(self, cr, uid, ids, context=None):

mod_obj = self.pool.get('ir.model.data')

res = mod_obj.get_object_reference(cr, uid, 'test_paie', 'test_paie_form')

momo_id = self.read(cr, uid, ids,['id','year','period','employee_id'])

print("momo_id =" , momo_id)

ref_id = self.check_data(cr, uid,momo_id[0]['employee_id'][0],momo_id[0]['year'],momo_id[0]['period'])

return {

'name': 'New Data',

'view_type': 'form',

'view_mode': 'form',

'view_id': [res and res[1] or False],

'res_model': 'test_paie',

'context': {'default_employee_id':momo_id[0]['employee_id'][0],'default_period' : str(momo_id[0]['period']), 'default_year' : str(momo_id[0]['year'])},

'type': 'ir.actions.act_window',

'nodestroy': True,

'target': 'new',

'flags' : { 'action_buttons' : True,},

'res_id': ref_id,

}

return {}

Avatar
Discard
Best Answer

Drees,

If you used the wizard, the Save and Close buttons(on footer) will automatically close the pop up. If you are doing a call of method from wizard, you must return {'type': 'ir.actions.act_window_close'} and your purpose will be served.

If you used dialog box from JS, you must use window.close for that.

How did you manage to add the pop up?

Thanks.

Avatar
Discard
Best Answer

Hey,

I had the same issue and I solve it by adding footer to the form view :

<footer>
<field name="id" invisible="1"/>
<button string="Create" name="action_close" type="object" class="btn-primary"
attrs="{'invisible': [('id', '!=', False)]}"
/>
<button string="Save" name="action_close" type="object" class="btn-primary"
attrs="{'invisible': [('id', '=', False)]}"
/>

<button string="Cancel" class="btn-secondary" special="cancel"/> footer>

then In my model i define the function action_close : 


def action_close(self):
return {'type': 'ir.actions.act_window_close'}




Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
262
1
Oct 24
328
4
Oct 24
323
2
Oct 24
359
2
Dec 24
661